I want to create a data structure that will be parse as a JSON object. The out put must look like this and this should be a dynamic data structure.
{"data": [{"type": "locale", "lat": -34.43778387240597, "lon": 150.04799169921876},
{"type": "poi", "lat": -34.96615974838191, "lon": 149.89967626953126},
{"type": "locale", "lat": -34.72271328279892, "lon": 150.46547216796876},
{"type": "poi", "lat": -34.67303411621243, "lon": 149.96559423828126}]}
I’m struggling in the middle of implementing this data structure so expecting some good ideas.
Thanks
Your question is unclear, but do you want probably something like this:
You can create this by creating a
DataResultclass and overriding the__str__or__unicode__methods.Your
add_poican be something like:where
PoiDatais another class representing a data entry of type “poi” etc.