fork(3) download
  1. import json
  2. import sys
  3. from collections import OrderedDict
  4.  
  5. L = json.load(sys.stdin, object_pairs_hook=OrderedDict)
  6. seen = OrderedDict()
  7. for d in L:
  8. oid = d["obj_id"]
  9. if oid not in seen:
  10. seen[oid] = d
  11.  
  12. json.dump(seen.values(), sys.stdout, indent=2)
Success #stdin #stdout 0.02s 8184KB
stdin
[
  {"obj_id": 123,
    "location": {
      "x": 123,
      "y": 323
  }},
  {"obj_id": 13,
    "location": {
      "x": 23,
      "y": 333
  }},
 {"obj_id": 123,
    "location": {
      "x": 122,
      "y": 133
  }}
]
stdout
[
  {
    "obj_id": 123, 
    "location": {
      "x": 123, 
      "y": 323
    }
  }, 
  {
    "obj_id": 13, 
    "location": {
      "x": 23, 
      "y": 333
    }
  }
]