Jump to content

json dedpulication

Bartb56

Hey guys im trying to deduplicate a external json file the json file looks like this

 [{"id":1,"firstName":"Krisha","lastName":"Shenfisch", "city":"Zwolle"},
{"id":2,"firstName":"Ad","lastName":"Buesden", "city":"Hengelo"},
{"id":3,"firstName":"Wilma","lastName":"Dyerson", "city":"Enschede"},
{"id":4,"firstName":"Drew","lastName":"Chattelaine", "city":"Amsterdam"},
{"id":5,"firstName":"Esteban","lastName":"Beniesh", "city":"Amsterdam"}]

 

now i want to make it so the it would not show the same city twice, i have no clue on how to do this im using js

Link to comment
Share on other sites

Link to post
Share on other sites

Hey man. In future please use 

code tags like this.

It'll make it a bit easier for others to read it. 
Anyway, If i understand correctly, you want to only pick the first person from each city?

Link to comment
Share on other sites

Link to post
Share on other sites

wrap them by city, person like this:

 

{
  "Amsterdam": {
    "1" : {
      "id":4,"firstName":"Drew","lastName":"Chattelaine"
    },
    "2" : {
      "id":5,"firstName":"Esteban","lastName":"Beniesh"
    }
  }
}

 

 

 

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Yesi o

1 minute ago, vorticalbox said:

wrap them by city, person like this:

 


{
  "Amsterdam": {
    "person" : {
      "id":4,"firstName":"Drew","lastName":"Chattelaine"
    },
    "person" : {
      "id":5,"firstName":"Esteban","lastName":"Beniesh"
    }
  }
}

 

I need it so I can see the the city just once but i also need it so i can see the city as many times as it is in the file now, sorry this is difficult to explain, this is a part of my assignment

 

 

1 minute ago, vorticalbox said:

I need it so I can see the the city just once but i also need it so i can see the city as many times as it is in the file now, sorry this is difficult to explain, this is a part of my assignment,

 

Develop a view where the total number of profiles is displayed. Show a list of all fields found and per field a checkbox the user can check to define on which fields they want to deduplicate. When a checkbox is switched it should instantly recalculate the new number of deduplicated profiles. A textfield should show that number to the user. The view would be similar to the one below.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

So you want to be able to count how many different cities there are or how many different names there are etc...?

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×