deserialize Jackson object in JavaScript containing JsonIdentityInfo

前端 未结 2 1767
独厮守ぢ
独厮守ぢ 2020-11-30 07:24

hello (sorry for my english)

I\'m working on angularjs front end website consuming web service producing json with SPRING MVC. The spring mvc use JsonIdentityInfo op

2条回答
  •  独厮守ぢ
    2020-11-30 07:50

    I recently came across an exact scenario that OP has described here. Below was my solution. Use JSOG (Javascript Object Graph) format to solve this.

    Server Side Use Jackson-Jsog plugin https://github.com/jsog/jsog-jackson and annotate each class using below annotation.

    @JsonIdentityInfo(generator=JSOGGenerator.class)

    instead of the

    @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id")

    this would generate in JSOG format. (@id and @ref)

    On the Client Side, use the jsog.js

    convert the JSOG structure to the cyclic one using the below call

    cyclicGraph = JSOG.decode(jsogStructure);

提交回复
热议问题