mercredi 23 novembre 2016

which pattern should i use when i have json to parse to objects

i have large json which im parsing , this json holds objects and objects properties and object actions . something like this :

[{

  "Obj1_type" : "o1",
  "Obj1_name" : "o1_name",
  "pos": {
       x:20,
       y:20
   }
}
,
{

  "Obj2_type" : "o2",
  "Obj2_name" : "o2_name",
  "pos": {
       x:40,
       y:40
   },
   "method": {
         "name": "move" ,
          "arg1: 1,
          "arg2: 2
}
,
{

  "Obj2_type" : "o2",
  "Obj2_name" : "o2_name",
  "pos": {
       x:40,
       y:40
   },
   "method_1": {
         "name": "move" ,
          "arg1: 1,
          "arg2: 2
    },
    "method_2": {
         "name": "jump" ,
          "arg1: 1 
    }
}
]

i have different objects each object contains different properties what will be the best pattern for this ?

Aucun commentaire:

Enregistrer un commentaire