Help converting a complex json object
See original GitHub issueHi,
I have a json object, its not complex but what I want to end up, is a little difficult for me to understand how to do this. The standard JSON object (represented by a typescript interface) is this
{
"_embedded": {
"record": {
"name": "CompanyA",
"meta": {
"address": "6 some street",
"stateCountry: "NY, USA"
}
}
},
"pageData": {
"pagination" : {
"page": 1,
"totalPages": 1
}
}
}
I want to end up with the following, represented by a typescript class
export class Item {
name: string // this comes from __embedded/record/name
address: string // this comes from __embedded/record/meta/address
state: string // this comes from __embedded/meta/stateCountry (split by coma, FIRST part)
country: string // this comes from __embedded/meta/stateCountry (split by coma, SECOND part)
pagination : Pagination
}
export class Pagination {
page: number //this comes from __embedded/pageData/pagination/page
totalPages: number //this comes from __embedded/pageData/pagination/totalPages
hasNext: boolean // this uses the above 2 properties to work out if there is a nextPage, true/false
}
Any help really appreciated
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
54. Convert Nested JSON Object Response To ... - YouTube
There are several ways of extracting values from JSON responses. We have already learnt to extract values from JSON responses using JSON ......
Read more >How Convert Complex Json String to Object - java
Try to change all your class to public (including your additionalinfo. It may help. As I know some of JSON parser do not...
Read more >How to Deserialize a Complex JSON Object in C# .NET
In this article, we are gonig to learn how to deserialize a complex JSON object using C# as our language of choice.
Read more >Data Extraction: Parse a 3-Nested JSON Object and ...
We can use the requests package for this purpose. To get the data as a JSON output, we call the **request.get **method. The...
Read more >Extract Nested Data From Complex JSON
Never manually walk through complex JSON objects again by using this function. We're all data people here, so you already know the scenario....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry @emyann , I think that was a comment I left previously, I actually deleted it because sure enough, it was as easy as that.
Although it got it on iteretee
That was perfect! Thank you!