Unable to load json from file

I am unable to load JSON from a file. I have taken the 05_tree_checkboxes.html sample and modified it to try to use JSON for the first tree. My HTML file is attached, but here is the relevant script that tries to load the JSON into my tree:

tree = new dhtmlXTreeObject(“treeboxbox_tree”, “100%”, “100%”, 0);
tree.setSkin(‘dhx_skyblue’);
tree.setImagePath(“codebase/imgs/csh_bluebooks/”);
tree.enableCheckBoxes(1);
tree.setXMLAutoLoading(“common/test.json”);
tree.setDataMode(“json”);
tree.loadJSON(“common/test.json?id=0”);

My JSON is in the file common/test.json and has the following content:

{
“id” : “0”,
“text” : “Test”
}

When I load my page I get an error dialog when trying to load the JSON file. The error is:

LoadXML
Description: Incorrect JSON

I can’t figure out why this won’t load. I did make a local change to the LoadJSON routine to see if I could get more information from the exception that is raised. What I got back was HTML including:

HTTP Status 404 - Not Found
Status report
message - Not Found
description - The requested resource is not available.

I’m not sure if this helps or not. The file is definitely there, and has appropriate permissions.

What am I doing wrong?

Thanks!

I am unable to upload the HTML file, so here it is…

Test
Two state checkboxes

Check item

UnCheck item

Check branch

UnCheck branch

Get list of checked

Three state checkboxes

Check item

UnCheck item

Get list of checked

Locally everything works. Could you provide completed demo on support@dhtmlx.com with a link on this topic?
docs.dhtmlx.com/doku.php?id=othe … leted_demo

I have just emailed the complete demo to support@dhtmlx.com.

For debugging, I changed my loadJSON routine to this:

dhtmlXTreeObject.prototype.loadJSON = function (a, b) {
this.parsCount || this.callEvent(“onXLS”, [this, this._ld_id]);
this._ld_id = null;
this.xmlstate = 1;
var d = this;
this.XMLLoader = new dtmlXMLLoaderObject(function (a, b, e, g, h) {
try {
eval(“var t=” + h.xmlDoc.responseText)
} catch (i) {
dhtmlxError.throwError(h.xmlDoc.responseText, “Incorrect JSON”, [h.xmlDoc, this]);
return
}
var j = new jsonPointer(t);
d._parse(j);
d._p = j
}, this, !0, this.no_cashe);
if (b) this.XMLLoader.waitCall = b;
this.XMLLoader.loadXML(a)
};

The only change is that when an exception is raised I print out h.xmlDoc.responseText. That results in this output in the resulting dialog:

Error type: Apache Tomcat/7.0.42 - Error report

HTTP Status 404 - Not Found


type Status report

message Not Found

description The requested resource is not available.


Apache Tomcat/7.0.42


Description: Incorrect JSON

It seems odd to me that a routine to load JSON is using an XML loader, but I probably don’t understand what is going on well enough.

Oh, i really sory that didn’t find your wrong json in a big part of the text… :frowning:
You have not right syntax:
{
“id” : “0”,
“text” : “Test”
}
You need the next:

{id:'0', item:[ {id: 'item1', text: 'Test'} ]}
The root is can’t have a text.