how to remove duplicates from a json file? code example

Example 1: js remove json value duplicates

var json = [
    {"text":"menu1","parent":"#","id":"128102"},
    {"text":"menu1.1","parent":"128102","id":"128103"},
    {"text":"menu1.1","parent":"128102","id":"128103"}
];

var ids = [];
var clean = [];

$.each(json, function(index, value) {
    if($.inArray(value.id, ids) == -1)
    {
        ids.push(value.id);
        clean.push(value);
    }
});

Example 2: removing duplicates using json python

all_ids = [ each['obj_id'] for each in ds ] # get 'ds' from above snippet
unique_stuff = [ ds[ all_ids.index(id) ] for id in set(ids) ]