-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.

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. Commented Jul 6, 2016 at 20:36

2 Answers 2

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 );

Sign up to request clarification or add additional context in comments.

Comments

0

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

that was your question?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.