Zegg90
01-15-2008, 05:19 PM
I am new to JSON, so I am just trying stuff out for my PHP application before I use it.
I have a question, is this valid JSON?
{"name": "Test Package", /* Required or 'Untitled' (default value) */
"author": "Zeggy", /* Optional, maybe a default value */
"version": 1.1, /* Version, must be a number */
"actions": [
{
"name": "Adding test code", /* Name for this particular process, required */
"file": "edit_me.php", /* Required */
"action": "add", /* choose out of [add, remove, replace], is required */
"type": "before", /* before, after */
"where": "$test = \"123321\";", /* Code to search for */
"code": "blabla
blabla
more code" /*Code to add/remove/replace */
},
{
"name": "Removing a comment",
"file": "another_file.php", /* Required */
"action": "remove",
"code": "\/\/This is a PHP comment!\\n" /* Removing this comment, 'where' not required */
},
{
"name": "Replacing $var1",
"file": "replace.php", /* Required */
"action": "replace",
"where": "$var1 = \"var numba 1\";", /* Find this string */
"code": "$var2 = \"new var #2\";" /* Replace with this */
}
]
}
Would this work if I used PHP to change it into an object/array?
And are the comments allowed?
Any other observations? :)
Thanks!
I have a question, is this valid JSON?
{"name": "Test Package", /* Required or 'Untitled' (default value) */
"author": "Zeggy", /* Optional, maybe a default value */
"version": 1.1, /* Version, must be a number */
"actions": [
{
"name": "Adding test code", /* Name for this particular process, required */
"file": "edit_me.php", /* Required */
"action": "add", /* choose out of [add, remove, replace], is required */
"type": "before", /* before, after */
"where": "$test = \"123321\";", /* Code to search for */
"code": "blabla
blabla
more code" /*Code to add/remove/replace */
},
{
"name": "Removing a comment",
"file": "another_file.php", /* Required */
"action": "remove",
"code": "\/\/This is a PHP comment!\\n" /* Removing this comment, 'where' not required */
},
{
"name": "Replacing $var1",
"file": "replace.php", /* Required */
"action": "replace",
"where": "$var1 = \"var numba 1\";", /* Find this string */
"code": "$var2 = \"new var #2\";" /* Replace with this */
}
]
}
Would this work if I used PHP to change it into an object/array?
And are the comments allowed?
Any other observations? :)
Thanks!