My JSON data used to be sent "flat" and I have encountered 2 issues with this format.
For example, here is a TypeScript class model:
UserID: number;
AppID: number;
Key: string;
HearingsAndEventsType: number
In the past, I would send the above data like this:
{
"UserID": 61525,
"AppID": 15,
"Key": "abc",
"HearingsAndEventsType": 1
}
However, now I am required to send the data as a nested object with two changes to the JSON structure:
- "PageQueryString": {...
- }, "HearingsAndEventsType": 1
This means that the mandatory structure I need to send looks like this instead:
{
"PageQueryString": {
"UserID": 61525,
"AppID": 15,
"Key": "abc"
},
"HearingsAndEventsType": 1
}
I previously posted a question on Stack Overflow asking for assistance regarding this issue. The question can be found at the following link:
Angular Typescript sending complex json data to web api when model is flat
Essentially, I have been using JSON stringify to send the model over, but adjustments are needed in order to structure the JSON correctly.
getPageCommonData(menu: Menu) {
return this.http.post(pageCommonData, JSON.stringify(menu), httpOptions)
....
}