java - Deserialize. Store only unique property values -


i use spring boot 1.5.6 + jackson, , when deserialize json :

{     "places": [{"name": "place1"}],     "zone_id": 1 }, {     "places": [{"name": "place2"}],     "zone_id": 2 }, {     "places": [{"name": "place1"}],     "zone_id": 3 } 

i following response:

{     "places": [{"name": "place1", "place_id": 1}],     "zone_id": 1 }, {     "places": [{"name": "place2", "place_id": 2}],     "zone_id": 2 }, {     "places": [{"name": "place1", "place_id": 3}],     "zone_id": 3 } 

but value "place1" duplicated, , don't want store copy in storage. Аdvise, pleace, how following response:

{     "places": [{"name": "place1", "place_id": 1}],     "zone_id": 1 }, {     "places": [{"name": "place2", "place_id": 2}],     "zone_id": 2 }, {     "places": [{"name": "place1", "place_id": 1}],     "zone_id": 3 } 

in modal following java class:

@entity @table(name = "place") public class place implements serializable {  @id @generatedvalue(strategy = generationtype.identity) @column(name = "place_id") @jsonproperty("place_id") private long id;  @column(name = "name") private string name;  @manytomany(fetch = fetchtype.lazy, mappedby = "places") @jsonignore private set<zone> zone = new hashset<zone>();  public place() { }  public place(string name, set<zone> zone) {     this.name = name;     this.zone = zone; }  get, set.... 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -