Java Spring、REST、Jackson和循环层次结构
假设我有以下实体层次结构Java Spring、REST、Jackson和循环层次结构,java,spring,spring-mvc,jackson,Java,Spring,Spring Mvc,Jackson,假设我有以下实体层次结构 class Parent { Long id; List<Child> children; } 我希望能够提出两种类型的REST请求: /应返回的家长/1: { "id": "1", "children": [{"id": 1, /* probably some other fields */}] } /儿童/1 { "id": "1", "parent": {"id": 1, /* some other fields */} }
class Parent {
Long id;
List<Child> children;
}
我希望能够提出两种类型的REST请求:
{
"id": "1",
"children": [{"id": 1, /* probably some other fields */}]
}
{
"id": "1",
"parent": {"id": 1, /* some other fields */}
}
{
"id": "1",
"parent": {"id": 1, /* some other fields */}
}