I have some JSON data that is saved in a text area as a string. Whilst it looks like JSON, it's technically speaking; not JSON.
How can I convert this string into an array in PHP? Here is an example of latitude and longitude coordinates that will be used on a Google Map:
String:
[{lng: -0.000000, lat: 10.000000},{lng: -0.000000, lat: 10.000000},{lng: -0.000000, lat: 10.000000},{lng: -0.000000, lat: 10.000000}]
PHP:
// get the coordinates
$coords = coordinates( 123 );
// Encode it into actual JSON
$coords = json_encode( $coords );
// Decode it into an array
$coords = json_decode( $coords, true );
If I then use var_dump( $coords );, it prints out the data as a string. What am I doing wrong here? I've looked at the plethora of other questions about this and none solve this issue. It just doesn't seem to work the same way.
json_decodefunction will convert it to an array, but I suppose my issue here is convert this string into valid JSON data to begin with.