为什么json只显示结果数据序列化中已经序列化的对象的id?

时间:2016-12-08 02:35:28

标签: java json

我很好奇这个休息返回用id来代替对象序列化。

当我使用rest和复杂类时,我开始注意到它们的响应体包含id代替一个对象,如id为2的“supplier”,id为3的“item”和id为5的“仓库”:

{
   "code": 1,
   "message": "Entities returned Successfully !",
   "t":    [
            {
         "@id": 1,
         "id": 2,
         "date": "01/02/2016",
         "supplier":          {
            "@id": 2,
            "id": 2,
            "code": "codfor",
            "name": "namfor"
         },
         "item":          {
            "@id": 3,
            "id": 2,
            "code": "code",
            "descricao": "descricao",
            "unity":             {
               "@id": 4,
               "id": 2,
               "unity": "nomeb"
            },
            "total": 11.33,
            "warehouse":             {
               "@id": 5,
               "id": 2,
               "local": "localb",
               "row": "corredorb",
               "shelf": "prateleirab",
               "floor": "andarb",
               "box": "boxb",
               "unity": 4,
               "total": 22.66,
               "items":                [
                  3,
                  3
               ]
            }
         },
         "warehouse": 5,
         "note": 22222,
         "size": 1.44,
         "price": 33.44
      },
            {
         "@id": 6,
         "id": 3,
         "date": "01/02/2016",
         "supplier": 2,
         "item": 3,
         "warehouse": 5,
         "note": 22222,
         "size": 1.44,
         "price": 33.44
      }
   ]
}

所以这是我项目中的一个功能或错误? 在spring或甚至json中设置完整序列化的属性或修复位置在哪里?

0 个答案:

没有答案