Hi I am very poor at building JSON data as I wanted to understand JSON better. I have read JSON.org but it is very limited in information. Therefore I have poor understanding JSON. However I am closer to getting the result.
$data = array('title'=>'JSON Sample Data',
'items'=> array('name' => 'text','value' => 'text date'),
('name' => 'integer','value' => 100),
('name' => 'float','value' => 5.65),
('name' => 'boolean','value' =>false)
);
$output = json_encode($data);
print_r ($output);
echo $output;
So I got error here and I do not have any idea what went wrong with JSON structure.
You're building it wrong (syntax error - missing array
keywords):
$data = array(
'title' => 'JSON Sample Data',
'items' => array(
array('name' => 'text','value' => 'text date'),
array('name' => 'integer','value' => 100),
array('name' => 'float','value' => 5.65),
array('name' => 'boolean','value' =>false),
),
);
Good indentation goes you a long way. :)