Steph
Steph

Reputation: 350

What is the difference between a JSON object and a JSON document?

I'm working with some data in React/Flux/Prismic. When I get it back from the API it comes through as what looks like a json object, but the console says its a "Document". Then when I get the data from my Flux store, it apparently goes through a change because the console now logs it as an "Object". The two look identical. What is the difference? See a screencap below. enter image description here

I'm trying to run a prismic specific function on the returned object, but I think it must be looking for the "Document object" format because when I do it in the component and it returns as a "Document object" the function works, but it won't work on the "Object object".

Upvotes: 2

Views: 2141

Answers (1)

Felix Kling
Felix Kling

Reputation: 816422

What you are looking at has nothing to do with JSON. This is simply how Chrome displays objects in the console.

The leading name (Document, Object) indicates the type of the object. Chrome will determine this type based on certain heuristics (which I don't know).

Maybe the objects have different prototypes, and that's why it shows a different type name.

Upvotes: 2

Related Questions