0
내 편안한 API에서 json-jackson을 사용하여 JSON 출력을 생성합니다. 그래서 JAXB-annotatied 한 클래스 : JAXB가 HashMap 키로 사용될 때 Annotatied 클래스 인스턴스를 마샬링하지 않는 이유는 무엇입니까?
@XmlRootElement(name = "Vertex")
@XmlType(propOrder = { "id", "label" })
@XmlAccessorType(XmlAccessType.NONE)
public class RepresentedVertex implements Vertex
{
private Vertex originalVertex;
@XmlAttribute(name = "id")
public String getId()
{
return this.id().toString();
}
@XmlAttribute(name = "label")
public String getLabel()
{
return this.label();
}
public RepresentedVertex(Vertex originalVertex)
{
super();
this.originalVertex = originalVertex;
}
...
@Override
public String toString()
{
StringBuffer buf = new StringBuffer();
buf.append("[").append(this.getId()).append("::").append(this.getLabel()).append("]");
return buf.toString();
}
내가 엔티티와 응답을 반환
=List<RepresentedVertex>
모두 OK입니다 - 나는
ID 및
라벨 주석 GET-방법에 따라 값을 넣어 JSON을 얻을.
하지만 키로 RepresentedVertex을 포함 Map<RepresentedVertex,List <RepresentedVertex>>
를 반환 할 때 - 나는 RepresentedVertex.toSting()
방법의 결과 출력을 얻을 (예 : [1245311 :: testLabel]) 같은지도 키 :
{
"status": "OK",
"message": "Ok complete",
"content": {
"[1245311::testLabel]": [
{
"id": "163852352",
"label": "dataset"
},
{
"id": "163864664",
"label": "dataset"
}
]
}
}
...하지만 나는 ID 및 라벨 같은 값을 구분합니다 :
{
"status": "OK",
"message": "Ok complete",
"content": {
"vertex": { "id": "1245311", "label": "testLabel"}: [
{
"id": "163852352",
"label": "dataset"
},
{
"id": "163864664",
"label": "dataset"
}
]
}
}
이지도 키의 JAXB-표현에 어떤 문제가 사건?
귀하의 질문에'하지 분명하다 [1245311 : testLabel] 당신의 toString' – Ravi
내가 추가 한'재정의로'명백하다 some clarification – palandlom
단지 당신이 알기를 바랍니다. 당신이 기대하는 것은 정확한 JSON이 아니기 때문에 할 수 없습니다. JSON의 유효성을 확인하려면 https://jsonlint.com/ – Ravi