I am having the JSon file that includes the following items:
{
"resource":"A",
"literals":["B","C","D"]
}
I would like to retrieve the items B, C and D only and store them in an array as strings. Here is my code:
<script>
// Reading the JSon file that has the items above
$.getJSON( "/Users/Docs/sample.json", function( data ) {
$.each( data, function( key, val ) {
items.push( "<li id='" + key + "'>" + val + "</li>" );
});
</script>
Could anyone please help me to get only B, C and D and sore them in an array of strings so I can reuse them for later in another script? Your help would be very much appreciated.
data.literalswill be your array of strings.B,CandDare already stored as strings in an array, just usedata.literalsto get them