对象列表的JSON结构 [英] JSON Structure for List of Objects

查看:165
本文介绍了对象列表的JSON结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道JSON中对象列表的正确结构。

I would like to know, whats the right structure for a list of objects in JSON.

我们正在使用JAXB将POJO转换为JSON。

We are using JAXB to convert the POJO's to JSON.

以下是选择,请指示我什么是正确的。

Here is the choices, Please direct me what is right.

foos: [
             foo:{..},
             foo:{..}
      ]

   foos : [
           {...},
           {...}
          ]

如果第一个结构是正确的,那么JAXB注释是什么?应该用来使结构正确。

If the first structure is right, what is the JAXB annotation I should use to get the structure right.

推荐答案

第一个是无效的语法。您不能在普通数组中包含对象属性。第二个是正确的,虽然它不是 strict JSON。它是JSON的宽松形式,其中字符串键中的引号被省略。

The first one is invalid syntax. You cannot have object properties inside a plain array. The second one is right although it is not strict JSON. It's a relaxed form of JSON wherein quotes in string keys are omitted.

Patrick Hunlock的本教程,可能有助于了解JSON和此网站可能有助于验证JSON。

This tutorial by Patrick Hunlock, may help to learn about JSON and this site may help to validate JSON.

这篇关于对象列表的JSON结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆