Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

including another file #2016

Closed
RiccardoRossi opened this issue Mar 27, 2020 · 5 comments
Closed

including another file #2016

RiccardoRossi opened this issue Mar 27, 2020 · 5 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@RiccardoRossi
Copy link

  • 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

@dota17
Copy link
Contributor

dota17 commented Mar 28, 2020

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

@RiccardoRossi
Copy link
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

@nlohmann
Copy link
Owner

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

@RiccardoRossi
Copy link
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.

@nlohmann
Copy link
Owner

nlohmann commented Apr 4, 2020

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:/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.

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

3 participants