Is anyone able to give me an insight how to use PHP classes to generate a JSON structure based on the following template
{
"Summary": "A long route",
published": true,
"Route 1": [
{
"Lat": 23.4,
"Long": 34.5
},
{
"Lat": 27.4,
"Long": 384.5
} ...
]
"Route 2": [
{
"Lat": 25.4,
"Long": 34.5
},
{
"Lat": 29.4,
"Long": 384.5
} ...
]......
}
I am able to generate a constructor function that allows me to instantiate the classes using the method of $routes['Route 1'] = new Route[32.4,34.5] but I am not sure how to generate additional waypoints, or Lat and Long elements for a say Route 1, without re-instantiating the Route class.
addWaypoint()andremoveWaypoint()?json_encode()to build a json string arn't you. You are not trying to build the string manually in a text string are you