Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deserialization of Object serialized by @JsonIdentityInfo

I am having my User class annotated like this to remove cyclic format of output:

@Entity
@Table(name = "USER")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = User.class)
public class User extends AbstractValueObject {
    private Integer id;
    private String name;
 .....
}

public class Load extends AbstractValueObject {
    private Integer id;
    private User postedBy;
}

So whenever i fetch List of Load it is giving me output as below JSON :

[
  {
   "id" : 1,
   "postedBy" : {
                  "id":1,
                  "name":"SOF"    
                }
  },
  {
   "id" : 2,
   "postedBy" : 1
  }
]

But client side wants it in original format - say each object of load should contain full postedBy object. Client side is in Android - Java.

Is there any way at Android end to de-serialize object in original format at Android ?

Expected output :

   [
      {
       "id" : 1,
       "postedBy" : {
                      "id":1,
                      "name":"SOF"    
                    }
      },
      {
       "id" : 2,
       "postedBy" : {
                      "id":1,
                      "name":"SOF"    
                    }
      }
    ]

I tried with JSOG but in some cases it fails.

Any help will be appreciated. :)

like image 761
Vishw Patel Avatar asked Jan 22 '26 02:01

Vishw Patel


1 Answers

You can use Jsog Converter, which provide library to encode and decode objects. https://github.com/jsog/jsog

like image 139
Naitik Soni Avatar answered Jan 23 '26 16:01

Naitik Soni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!