Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
aa166a47
Commit
aa166a47
authored
Jan 04, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated examples
parent
77ea63ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
2 deletions
+40
-2
README.md
README.md
+40
-2
No files found.
README.md
View file @
aa166a47
...
...
@@ -36,7 +36,28 @@ to the files you want to use JSON objects. Furthermore, you need to compile the
## Examples
Here are some examples to give you an idea how to use the class:
Here are some examples to give you an idea how to use the class.
Assume you want to create the JSON object
```
json
{
"pi"
:
3.141
,
"happy"
:
true
,
"name"
:
"Niels"
,
"nothing"
:
null
,
"answer"
:
{
"everything"
:
42
},
"list"
:
[
1
,
0
,
2
],
"object"
:
{
"currency"
:
"USD"
,
"value"
:
"42.99"
}
}
```
With the JSON class, you could write:
```
cpp
// create an empty structure (null)
...
...
@@ -62,9 +83,26 @@ j["list"] = { 1, 0, 2 };
// add another object (using an initializer list of pairs)
j
[
"object"
]
=
{
{
"currency"
,
"USD"
},
{
"value"
,
"42.99"
}
};
// instead, you could also write (which looks very similar to the JSON above)
JSON
j2
=
{
{
"pi"
,
3.141
},
{
"happy"
,
true
},
{
"name"
,
"Niels"
},
{
"nothing"
,
nullptr
},
{
"answer"
,
{
{
"everything"
,
42
}
}},
{
"list"
,
{
1
,
0
,
2
}},
{
"object"
,
{
{
"currency"
,
"USD"
},
{
"value"
,
"42.99"
}
}}
};
*/
```
Note that in all cases,
the compiler derives the appropriate JSON valu
e.
Note that in all cases,
you never need to "tell" the compiler which JSON value you want to us
e.
### Serialization / Deserialization
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment