Java – Split JSON Object

androidjavajson

I'm working on a D3 DPS calculator and i'm having a problem with a JSON-Object.
I get a JSON-Object like this:

{"Sockets":{"min":1,"max":1},
"Dexterity_Item":{"min":165,"max":165},
"Durability_Cur":{"min":581,"max":581},
"Durability_Max":{"min":715,"max":715},
"Attacks_Per_Second_Item_Percent":{"min":0.1,"max":0.1},
"Damage_Weapon_Delta#Arcane":{"min":315,"max":315},
"Damage_Weapon_Min#Arcane":{"min":274,"max":274},
"Damage_Weapon_Delta#Physical":{"min":161,"max":161},
"Damage_Weapon_Min#Physical":{"min":190,"max":190},
"Attacks_Per_Second_Item":{"min":1.2000000476837158,"max":1.2000000476837158},
"Steal_Health_Percent":{"min":0.03,"max":0.03}}

How can i split all of this values? I cant do it by name, because its "random". I would like to have a List with the stat and the value.

Best Solution

One thing that might help is to view your JSON in an online JSON viewer like this. You can hit format, and get something out of it that looks like this:

{
  "Sockets": {
    "min": 1,
    "max": 1
  },
  "Dexterity_Item": {
    "min": 165,
    "max": 165
  },
  "Durability_Cur": {
    "min": 581,
    "max": 581
  },
  "Durability_Max": {
    "min": 715,
    "max": 715
  },
  "Attacks_Per_Second_Item_Percent": {
    "min": 0.1,
    "max": 0.1
  },
  "Damage_Weapon_Delta#Arcane": {
    "min": 315,
    "max": 315
  },
  "Damage_Weapon_Min#Arcane": {
    "min": 274,
    "max": 274
  },
  "Damage_Weapon_Delta#Physical": {
    "min": 161,
    "max": 161
  },
  "Damage_Weapon_Min#Physical": {
    "min": 190,
    "max": 190
  },
  "Attacks_Per_Second_Item": {
    "min": 1.2000000476837158,
    "max": 1.2000000476837158
  },
  "Steal_Health_Percent": {
    "min": 0.03,
    "max": 0.03
  }
}

Also I really like this description for Android JSON parsing