How to set a link from one JSON object to another in a JSON file

Is there a way to set a link from one JSON object to another?

+8
json
source share
2 answers

Short answer: NO

JSON is a very simple data presentation format. It does not contain link support inside a shared object. Maybe you can hack a little, but he will still deal with the program.

+3
source share

Well, you can do such things, but don’t know what you are looking for:

<!DOCTYPE html> <html> <body> <script type="text/javascript"> Persona = { "numberOfLegs" : 2 }; Cesar = { "basics" : Persona, "name" : "Julio Cayo Cesar" } document.write( "<br>" + Cesar.name ); document.write( "<br>" + Cesar.basics.numberOfLegs ); </script> </body> </html> 

If you are looking for inheritance then the answer will definitely not be. The only way to do something like this is to use $.extend( dest, org ) with jQuery.

Hope this helps.

0
source share

All Articles