H
H
hatealleverything2020-10-17 12:10:48
JavaScript
hatealleverything, 2020-10-17 12:10:48

How can you remove duplicates in a json object?

"57939542_676854000": {
      "price": "15.95",
      "market_hash_name": "100-Proof Jug",
      "ru_rarity": "Common"
    },
    "57939545_0": {
      "price": "5.00",
      "market_hash_name": "Armor of the Radiant Crusader",
      "ru_rarity": "Common"
    },
    "57939545_679889639": {
      "price": "3.20",
      "market_hash_name": "Armor of the Radiant Crusader",
      "ru_rarity": "Common"
    },
    "57939546_676890580": {
      "price": "4.98",
      "market_hash_name": "Aspect Wraps of the High Plains",
      "ru_rarity": "Uncommon"
    },
    "57939548_0": {
      "price": "2.00",
      "market_hash_name": "Back Hook - Off-Hand",
      "ru_rarity": "Uncommon"
    },
    "57939548_680034817": {
      "price": "3.20",
      "market_hash_name": "Back Hook - Off-Hand",
      "ru_rarity": "Uncommon"
    },
    "57939549_679704489": {
      "price": "2.52",
      "market_hash_name": "Back Hook",
      "ru_rarity": "Uncommon"
    },
    "57939549_3863589862": {
      "price": "5.00",
      "market_hash_name": "Back Hook",
      "ru_rarity": "Uncommon"
    },
    "57939550_0": {
      "price": "2.70",
      "market_hash_name": "Back-Ache",
      "ru_rarity": "Common"
    },
    "57939550_673881884": {
      "price": "4.09",
      "market_hash_name": "Back-Ache",
      "ru_rarity": "Common"
    },
    "57939550_3992208124": {
      "price": "4.80",
      "market_hash_name": "Back-Ache",
      "ru_rarity": "Common"
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
d-sem, 2020-10-17
@hatealleverything

Parse the object. Filter data. Pack back.
If you need a simple uniqueness of data within an object, then simply calculate the hash for the values ​​of its fields. And if such a hash already exists, exclude the object from the array of objects.

K
kolebayevv, 2020-10-18
@kolebayevv

consider Set

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question