Hi I've been given the task of formatting JSON using any form of client side. At the moment the JSON is outputted in a standard format like this.
{"Art":[["1","Game Weapons","Weapons","11","GameWeapons_Final_Sheet.jpg"],["2","Violet","Scenery","11","Violet_sheetformat.jpg"]]}
To do this I am using PHP to extract the data and then encode
$jsondata = array();
while($row=mysqli_fetch_row($result))
{
$jsondata['Art'][]=$row;
}
echo json_encode($jsondata);
How do I go about formatting this data before printing and again it has to be client side. Nothing fancy is needed, just simple indenting so it can be read easier. Apologies if I've incorrectly posted or my question doesn't make sense
EDIT
I need my JSON to be indented like this using any client side language
{
"Art":[
[
"1",
"Game Weapons",
"Weapons",
"11",
"GameWeapons_Final_Sheet.jpg"
],
[
"2",
"Violet",
"Scenery",
"11",
"Violet_sheetformat.jpg"
]
]
}
EDIT 2
current code
<?php
include ("config/init.php");
$connection = mysqli_connect($hostname, $username, $password, $databaseName) or die("you did not connect");
$query = "SELECT * FROM art";
$result = mysqli_query($connection, $query) or die (mysqli_error($connection));
$jsondata = array();
while($row=mysqli_fetch_row($result))
{
$jsondata['Art'][]=$row;
}
$json = json_encode($jsondata);
?>
<script>
var obj = <?php echo $json; ?>;
var str = JSON.stringify(obj, undefined, 2);
document.write(str);
</script>
All done now, thankyou so much