Skip to content

including another file #2016

Closed
Closed

Description

@RiccardoRossi
  • Describe what you want to achieve.

I would like to include another json file within my json. Is there a way of doing it?

  • Describe what you tried.

the schema syntax would be something like

$ref:"/path/to/my/file.json"
  • Describe which system (OS, compiler) you are using.
    any

  • Describe which version of the library you are using (release version, develop branch).
    latest

Activity

  1. dota17 commented on Mar 28, 2020

    @dota17
    Contributor

    This library didn't support Json Reference now, so I'm afraid it can't do that.

  2. RiccardoRossi commented on Mar 30, 2020

    @RiccardoRossi
    Author

    ok, provided that we implement it within our wrapper around nlohmann (so that is it not an implementation problem) could u hint about what would be the "jsonic" way of achieving what we seek?

    I mean, implementing our own special handling of "$ref" would be a good choice or should we go for a different approach to be able to include one json inside the other

  3. nlohmann commented on Mar 31, 2020

    @nlohmann
    Owner

    @dota17 is right, the library does not support this.

  4. RiccardoRossi commented on Mar 31, 2020

    @RiccardoRossi
    Author

    Dear @nlohmann @dota17 i appreciate that (i also read it in your docs).

    We have a wrapper on the top of your lib which allows us to implement extra stuff. I was asking for a hint of what you think should be the best strategy to achieve it, not from a programming point of view but rather from a "json-organizational" point of view.

  5. nlohmann commented on Apr 4, 2020

    @nlohmann
    Owner

    You could do it either inside the parser writing your own SAX interface or you do it as post processing step after parsing. For the former, you may want to have a look at the json_sax_dom_parser (https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/json_sax.hpp#L145) parser. With some work, you should be able to add the required logic to replace $ref values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions