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.
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.
I have asked the backend team to return the second JSON to me since it more easier to get, but I still interested to know how to iterate the first JSON. I did parse the JSON.
DataResponse
Yeah well it looks like your model does not reflect the JSON you want to parse. You model looks like the second JSON snippet that you want the back-end team to send you.
Your Levels class holds a levelNo, but going by the JSON you received it should instead hold a Map<String, Level>, with Level being a separate class that has an id and a levelNo property.