I am working on Dynamic Web Project in Eclipse and using HTML 5 and Javascript as well. I could manage to parse JSON file that is saved locally in my system though the code below:
$.getJSON( "/Users/Documents/workspace2/sample.json", function( data ) {
var items = [];
$.each( data, function( key, val ) {
items.push( "<li id='" + key + "'>" + val + "</li>" );
});
$( "<ul/>", {
"class": "my-new-list",
html: items.join( "" )
}).appendTo( "body" );
});
Let's suppose this is the JSON file:
{"resource":"A","literals":["B","C","D"]}
My question is: Is there any possibility to have an array of strings to store these elements that are inside the JSON file after parsing. I am quite new to jQuery and couldn't really manage to see these elements stored in an array of strings, for example. Could anyone help me with this issue please.

data, which is an object at this point, to a variable that is scoped outside of thegetJSONcall but realizegetJsonis an asynchronous operation. So when this runs other things will continue to run until this completes then this will run the callback (the anon function you define in the call), so any variable you set inside of thegetJsoncallback may not be available when you need it.