Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set reference of one JSON object to another in JSON file

Tags:

json

Is there any way to set reference of one JSON object to another?

like image 921
Amar Avatar asked Jul 16 '12 09:07

Amar


People also ask

How do I reference a JSON file in another JSON file?

JSON doesn't have any mechanism to reference/include JSON in other files. You manually have to edit the JSON and insert your other JSON there. Or load both JSON files with whatever language you are processing the data in, and write some custom logic to merge the data in that language.

How do you reference an object in JSON?

In a JSON schema, a $ref keyword is a JSON Pointer to a schema, or a type or property in a schema. A JSON pointer takes the form of A # B in which: A is the relative path from the current schema to a target schema. If A is empty, the reference is to a type or property in the same schema, an in-schema reference.

Can JSON represent shared object references?

You can't. You can specify the path to the parent as a string and evaluate that at runtime, but as JSON is just strings, integers, arrays, and dictionaries, you can't use references.

Can a JSON value be another JSON object?

It is a common mistake to call a JSON object literal "a JSON object". JSON cannot be an object. JSON is a string format. The data is only JSON when it is in a string format.


1 Answers

Short answer: NO

JSON is a very simple data representation format. It contains no support for references within the overall object. May be you could hack up a little, but it will still be up to the program parsing it.

like image 88
UltraInstinct Avatar answered Oct 02 '22 09:10

UltraInstinct