4

With @JsonIdentityInfo we can do things like :

 {
    "@id" : 1,
    "value" : 13,
    "next" : {
       "@id" : 2,
       "value" : 42,
       "next" : 1
     }
  }

The reference is a primitive type. It it possible to have the reference be serialized as an object ? example :

 {
    "@id" : 1,
    "value" : 13,
    "next" : {
       "@id" : 2,
       "value" : 42,
       "next" : {"$ref":1}
     }
  }

EDIT

Usefull links

redben
  • 5,578
  • 5
  • 47
  • 63

1 Answers1

4

You can use "generator" property of the annotation to provide a custom ObjectIdGenerator that handles creation and binding of object ids.

However, current implementation does assume that the id is always a scalar type; either JSON String or Number. Support for JSON Objects has been requested, and there is at least one developer working on doing just this (for JSOG notation, similar to what you are trying to do here). You may want to join Jackson dev list to discuss this further.

StaxMan
  • 113,358
  • 34
  • 211
  • 239