-3

Recently, i have been working with JSON from a url. I was hoping to use only javascript to interact with the json file. Hence, i found out about this: How can I open a JSON file in JavaScript without jQuery? I used the answer from Drew, but the question now is how do i work with the Object?

Object {success: true, rgInventory: Object, rgCurrency: Array[0], rgDescriptions: Object, more: false…}

This is the result from using Drew's answer.

I hope my question is understandable.

Community
  • 1
  • 1
  • Btw, using jquery isn't necessarily a bad thing. It makes your code automatically cross-browser compliant, and usually makes things easier and take less lines of code. Sure, it's another small file the browser has to download, but with today's connection speeds, it doesn't make much of a difference. – frodo2975 Jul 06 '16 at 20:36

2 Answers2

2

So, JSON stands for Javascript Object Notation.

Think that as a way to describe a object in Javascript in a human readable manner.

So if you downloaded a JSON file it is a json in text plain format, in order to work with this you first need to transform this text notation in a actual object by parsing it.

Ex:

var asText = '{"hello": "world"}';

var asObject = JSON.parse( asText );

console.log( asObject.hello );
0

To access into success value write var successValue = object.success.

that was your question?

Rui Costa
  • 800
  • 4
  • 13