Domanda

I am newbie to dojo and json. I am trying to Query the server to get data as json and parse the result and use html template in a widget to display.

To test it I tried this.

      require(["dojo/request", "dojo/dom", "dojo/dom-construct","dojo/_base/array", "my/widgets/", "dojo/domReady!"],
function(request, dom,domConst, arrayUtil, support){
// Load up our authors
request("js/my/data/sample.json", {
    handleAs: "json"
}).then(function(LinksMap){
        // Get a reference to our container



    arrayUtil.forEach(LinksMap, function(List){
        // Create our widget and place it

       console.debug(LinksMap);
        //var widget = new support(author).placeAt(authorContainer);

Not sure if I am doing it right. Is there anything I am misssing. I am following the example as provided here and building on it.

È stato utile?

Soluzione

I think from the comments on your post you want to modified the deferred handling function to be

request("js/my/data/sample.json", {
    handleAs: "json"
}).then(function(jsonResults){
    console.log(jsonResults.Result)
});

The json you posted is an object with a property Result. The Result property contains an array of objects. Those objects then contain a property LinksMap which holds another object.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top