It is possible to reference to another JSON file for the value of a field?

27 Views Asked by At

After looking for this, I have found many examples and information on referencing an external json (file) for json schema information, using the "$ref" keyword. But nothing on referencing an external json file for the value of a field (object).

I have created a small proof of concept application to see if it is techinally possible to do using a well known json library "Sytem.Text.Json" (which can already do this referencing, but only within a file). And conceptually this works as I would want, using json like the example below.

{
  "$id": "1",
  "Father": {
    "$id": "2",
    "FirstName": "Adam",
    "LastName": "Doe",
    "Age": 45,
    "IsAdult": true,
    "Gender": 1,
    "Hobbies": {
      "$id": "3",
      "$values": [
        "Running",
        "Fishing"
      ]
    },
    "UniqueId": "5f106e44-dd5b-4fa7-a761-2ad6b342b52e"
  },
  "Mother": {
    "$ref": "Mother.json"
  }
}

But because I find no information on this use case, I am inclined not to do this if it is so uncommon.

The reason I am looking for this is to be able to split up a lenghty json file containing a large object with sub objects into multiple files where necessary. Both for performance reasons and for making reading, editing and general managing of all this json data easier outside of the application.

So to summarize, my questions are:

  • Is it possible to reference to another json file for the value of a field (object)?
  • Are there considerations to NOT do this? (like lack of widespread support)
0

There are 0 best solutions below