Hi Team,
I need to create a JSON from my php. As of now I am able to get the JSON, but it is needed in a different format.
Mentioned below is the code I am using
<?php
$connectString = 'host=localhost dbname=postgis_21_sample user=postgres password=postgresql';
$link = pg_connect($connectString);
if (!$link) {
echo "error";
} else {
$result = pg_query($link, $sql);
//$rows = array();
while($r = pg_fetch_assoc($result)) {
$rows[] = $r;
}
print json_encode($rows,true);
}
?>
Attached is the image json.png which show how the following code shows the output.
Attached is the image of the required format.
Please help me to get the desired format.
Thanks
Aditya Kumar
Json formats
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US