-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
JSON Data Mapping Key-Value from other Key-Value #2148
Comments
If you want to be able to create references like this, you may want to look at yaml (which is a superset of json) instead. It would look like this:
Again: This will not work with this library, or any other json library for that matter. This syntax is specific to yaml. |
@FrancoisChabot is right. Or do you just want to copy a value? |
Thanks for all reply. @nlohmann , yes actually I want to copy values. Basically in my datasets I'll have some large array's where multiple array will have same data values. Hence rather writing it manually if I can copy values from one key to another within the json, it will be great. Is it possible here? Regards. |
The following is possible: |
Understand ... but its inside the c++ code. I wanted to do it in the .json file itself. |
Then I would need a concrete code example. |
Meaning, I don't know exactly what you try to achieve. |
Ok, let me explain one again may be it will help to clarify. I have a json file hello.json like below: { Here my need is ... if I parse the Value of Key2 it will be Value of Key1 i.e. "Test". So is it possible to define the Value of Key2 in such a way in .json file, so it will contain Value of Key1 internally? Thanks. |
Then @FrancoisChabot understood you right, and this is not possible with JSON and this library. |
Noted with Thanks, |
Hi. It may very basic question ...
I want to map a Key-Value from another key-Value. Like, for example:
{
Key1: "Test",
Key2: "This will be Value of Key1"
}
In want the Key2 will be Value of Key1 i.e. "Test" when parsing.
Is there any way to define the JSON in such way?
Thanks.
The text was updated successfully, but these errors were encountered: