質問

JSON will normally encode an array of objects as something like:

"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Devil's Food" }
                    ]

Is there a way that I can encode such that it the object definition is declared only once so that the name of the fields are not specified in each array entry?

Thanks,

Art

役に立ちましたか?

解決

No. You have to repeat the field names in each entry.

JSON is deliberately very simple with generally only one way to express a particular data model, and sometimes this can make it a little more verbose.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top