Hello everyone, I am attempting to convert JSON data into an object array in order to add this data to a Kendo grid. However, I keep encountering the following error:
Uncaught (in promise): TypeError: Cannot read property 'slice' of undefined
This error indicates that my data format is incorrect!
Here is an example of how the data is structured in the JSON file:
[
{
"orderNumber": 1,
"orderTable": "905503111-9",
"orderDescription": "Nullam porttitor lacus at turpis. Donec posuere metus vitae ipsum. Aliquam non mauris.",
"orderDate": "5/4/2018",
"orderPrice": 79
}
]
What I want it to look like is:
{
"data": [
{
"orderNumber": 1,
"orderTable": "905503111-9",
"orderDescription": "Nullam porttitor lacus at turpis. Donec posuere metus vitae ipsum. Aliquam non mauris.",
"orderDate": "5/4/2018",
"orderPrice": 79
}
]
}
Below is an example of how I am currently accessing the JSON file (orders.ts):
import { orders } from './orders';
import { employees } from '../employee/employees';
@Component({
selector: 'app-order',
templateUrl: './order.component.html',
styleUrls: ['./order.component.css']
})
export class OrderComponent implements OnInit {
public result;
public data = orders;
}
I have tried various solutions like json.parse() and json.stringify(), but so far without success.
Just a reminder: I am utilizing a JSON file (orders.ts) that is present within my project.