Maybe your example will become more clear if you use real property names instead of "abc". Also, to me it doesn't make sense that a property named "companies" has an object value instead of an array. Can you verify that the response you get from the backend contains a property named "companies" that contains an object value?
I understand that in your front-end, given an object containing some properties, you want to send a request to the back-end that as the value of an "id" property, you want to use the key of the property from your original response. This is not conventional, but also not completely unheard of. It does imply to me that the application is not well designed though.
Can you tell us some more about the purpose of the application? That is, the original JSON is a response to a request for what exactly? And why do you need to select a specific property? What will you do with the specific property after you have selected it? Why?
The first version (theirs) has a single object in an array, which is incorrect. You want an array of companies.
The second version (yours) is invalid json. It doesn't need the repeat of the company name as a tag.
Wonder how could I loop through the levels list to get all the items if need written in dart language?
I guess it should be this?
Life is but a BREATH
Stephan van Hulst
posted 3 weeks ago
The first JSON you posted is valid, but doesn't make sense and is hard to work with. It's like you put a dictionary as the only element into a list.
The second JSON is much better, you actually have a list of levels. But what's the point of having both an "id" property and a "level_no" property if they're always going to have the same value? Just remove one of the two.
I don't understand your question. Are you asking us how to iterate a JSON array in the Dart language? First step is always to parse the JSON before you do any iterating.