jeudi 29 janvier 2015

Design pattern to use for building a JSONObject for Network calls

Consider the following JSONObject which needs to be posted to a WebService to retrieve data.



{
"Search":"red",
"Index": 0,
"Size": 2,
"filter": {
"flags": {
"processed": true,
"hascode": true,
},
"lists": {
"category": ["1","2"],
"attributevalue": ["1","2"]
},
}
}


Which Design pattern would best be suitable for building this which has different objects in it. In the following, list and flag are objects with their own values and are inside the filter object. i was thinking of using the composite pattern but i don't know if it would be best to have those objects in the root object constructor and i have not seen one(Composite pattern) which uses getters and setters implemented in their design(which is what am currently doing for everything in the root object). not sure if any issues will arise using my approach so far? Any better design implementation or is composite the way to go? Thank you.


Aucun commentaire:

Enregistrer un commentaire