Yes sorry, should have said what I’m trying to achieve here. I have a JSON response string as encoded by the getnodes.php processor, a sample from the start is :-
[{"text":"Page 3 (2)","id":"alt_2","pk":2,"leaf":1,"cls":"icon-document","type":"modResource","qtip"
:"<i><\/i>","preview_url":"http:\/\/10.92.20.228\/revolution\/index.php?id=2","href":"?a=40&id=2","menu"
:{"items":[{"id":"cm-resource-header","text":"<b>Page 3<\/b> <i>(2)<\/i>","params":"","handler":function
() { return false; },"header":true},"-",{"id":"cm-resource-view","text":"View Resource","handler":function
() {
this.loadAction("a=40");..........etc etc
If returned straight to my provisioner resource tree panel, which is derived from MODx.tree.Tree it displays fine, layout, names, qtips, menus etc all Ok.
What I want to do before I return it is to take off the menus it comes with and add my own, so I want to convert this string back to a PHP array, add my menus and re-encode it, then pass it back. I can see the re-encoding as the response object has the toJSON method, its the decoding that seems to break. the XPDO fromJSON just returns a null array, as it does if I do a decode_literals on it first(or encode_literals for that matter).
If you only do this in javascript maybe there isn’t a PHP equivalent yet in the code, I can’t seem to find one.
I could of course mung the JSON string but this is very kludgy. I’d rather dig into this by using a simple PHP script that instantiates the Services_JSON class from the json/JSON.php file and step through it to find out what’s occurring in the decode if needs be.