How would I express XML tag attributes in JSON?

后端 未结 13 2233
遥遥无期
遥遥无期 2020-12-07 20:35

I am designing an API for my webapp.

I was thinking to support only JSON responses (not XML) because more streamlined.

But I have just bumped to this XML:

13条回答
  •  余生分开走
    2020-12-07 21:28

    JSON is more uniform than XML and doesn't distinguish between plain-text attributes and hierarchical contents. The natural representation for your example would be

    [
      {"id": 123, "private": 0, "archived": 0, "order": 1, "name": "Shopping"}
    ]
    

    This is still more compact than the respective XML.

提交回复
热议问题