I need to access some variables from my site, elsewhere, via JSON.
All options will Always be defined. My question is, is it better to create a faux-json or use json_encode
. The faux json would look something like this:
{
"data": [
{
"optA": "<?php echo($optA); ?>",
"optB": "<?php echo($optB); ?>",
"optC": "<?php echo($optC); ?>"
}
]
}
I 'feel' like nesting arrays and using json_ecode
adds another step. Though, I know echo'ing out line by line adds some weight too.
I'd lean towards using json_encode
because it's widely used. My arrays won't be overly complex either, but definitely more-so than the example above.