1

My question is similar to deserialize Jackson object in JavaScript containing JsonIdentityInfo but I'm working with Java and I'm asking about jackson specifically, not 3rd party stuff.

I'm sending JSON from the server to the client. To save space I'm using @JsonIdentityInfo and the client receives:

[
  {
    "id": 1,
    "nestedObject": {
      "id": 2,
      "someInt": 2,
      "someString": "a"
    }
  },
  {
    "id": 3,
    "nestedObject": 2
  }
]

But the client needs the real/full JSON representation because it's working with parsers which are not JsonIdentityInfo-aware. Does Jackson have a way to "halfway deserialize" the compact representation into the full representation?

[
  {
    "id": 1,
    "nestedObject": {
      "id": 2,
      "someInt": 2,
      "someString": "a"
    }
  },
  {
    "id": 3,
    "nestedObject": {
      "id": 2,
      "someInt": 2,
      "someString": "a"
    }
  }
]
Mark
  • 2,167
  • 4
  • 32
  • 64
  • Only if new functionality will be written by Sherlock. Seems like you need to use Jackson views. Check this link please https://stackoverflow.com/questions/38279782/what-is-the-json-view-class-in-jackson-and-how-does-it-work. – eg04lt3r Jun 17 '17 at 12:15
  • @eg04lt3r i don't see how that solves anything. The link shows how to send 2 different JSON representations per demand. I want to send only one. – Mark Jun 17 '17 at 13:07
  • 1
    seems like jackson has not functionality to deserialize properly object marked as `@JsonIdentityInfo`. I think that only possible solution is to write custom deserializer. A lot of guys asked for this, but there is no solution out of the box in jackson. – eg04lt3r Jun 17 '17 at 13:56
  • Below approach helped in resolving similar issue: https://stackoverflow.com/a/76514182/11475829 – Guru Jun 20 '23 at 11:22

1 Answers1

1

After doing more research it seems it's impossible to do at this moment, as said in the comments.

Mark
  • 2,167
  • 4
  • 32
  • 64