I get this JSON from a server:
"Body": {
"ErrorsContent": {
"FunctionalError": [
{
"Code": "110900",
"Error": "xx",
"Position": "xx",
"Value": ""
},
{
"Code": "110900",
"Error": "xx",
"Position": "xx",
"Value": ""
},
{
"Code": "110900",
"Error": "xx",
"Position": "xx",
"Value": ""
},
{
"Code": "110902",
"Error": "xx",
"Position": "xx",
"Value": ""
},
{
"Code": "110900",
"Error": "xx",
"Position": "xx",
"Value": ""
}
]
}
}
I need it to parse to an Angular object, so I created a couple classes:
export class Body{
public ErrorsContent: ErrorsContent;
}
class ErrorsContent{
public FunctionalError: FunctionalError;
}
class FunctionalError{
public Code: any;
public Error: any;
public Position: any;
public Value: any;
}
But this does not work fine when I have more than one FuntionalError.
How can I set the
FuntionalErrorclass so that I can have more than one error without being a class itself?
Any advice is welcome! Thanks.
Codeas numbers and not as strings, 2) don't use the: anytype. Give it the right one → In your casestringor if you follow tip 1) alsonumberCodeshould becodein classes as well as from server response