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
442058f8
Commit
442058f8
authored
Aug 31, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interface cleanup
parent
afba1d3f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
62 additions
and
100 deletions
+62
-100
doc/examples/basic_json.cpp
doc/examples/basic_json.cpp
+0
-12
doc/examples/basic_json.link
doc/examples/basic_json.link
+0
-1
doc/examples/basic_json.output
doc/examples/basic_json.output
+0
-1
doc/examples/basic_json__istream.cpp
doc/examples/basic_json__istream.cpp
+3
-1
doc/examples/basic_json__istream.link
doc/examples/basic_json__istream.link
+1
-1
doc/examples/basic_json__nullptr_t.cpp
doc/examples/basic_json__nullptr_t.cpp
+6
-3
doc/examples/basic_json__nullptr_t.link
doc/examples/basic_json__nullptr_t.link
+1
-1
doc/examples/basic_json__nullptr_t.output
doc/examples/basic_json__nullptr_t.output
+1
-0
src/json.hpp
src/json.hpp
+25
-40
src/json.hpp.re2c
src/json.hpp.re2c
+25
-40
No files found.
doc/examples/basic_json.cpp
deleted
100644 → 0
View file @
afba1d3f
#include <json.hpp>
using
json
=
nlohmann
::
json
;
int
main
()
{
// create a JSON value with default null value
json
j
;
// serialize the JSON null value
std
::
cout
<<
j
<<
'\n'
;
}
doc/examples/basic_json.link
deleted
100644 → 0
View file @
afba1d3f
<a target="_blank" href="http://melpon.org/wandbox/permlink/dRptmFmhvpsYB49t"><b>online</b></a>
\ No newline at end of file
doc/examples/basic_json.output
deleted
100644 → 0
View file @
afba1d3f
null
doc/examples/basic_json__istream.cpp
View file @
442058f8
...
...
@@ -27,7 +27,8 @@ int main()
ss
<<
text
;
// create JSON from stream
json
j_complete
(
ss
);
json
j_complete
(
ss
);
// deprecated!
// shall be replaced by: json j_complete = json::parse(ss);
std
::
cout
<<
std
::
setw
(
4
)
<<
j_complete
<<
"
\n\n
"
;
...
...
@@ -51,5 +52,6 @@ int main()
// create JSON from stream (with callback)
json
j_filtered
(
ss
,
cb
);
// shall be replaced by: json j_filtered = json::parse(ss, cb);
std
::
cout
<<
std
::
setw
(
4
)
<<
j_filtered
<<
'\n'
;
}
\ No newline at end of file
doc/examples/basic_json__istream.link
View file @
442058f8
<a target="_blank" href="http://melpon.org/wandbox/permlink/VzSqLszbnoWE92dD"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="http://melpon.org/wandbox/permlink/R6dzpKXlxrttShf7"><b>online</b></a>
\ No newline at end of file
doc/examples/basic_json__nullptr_t.cpp
View file @
442058f8
...
...
@@ -4,9 +4,12 @@ using json = nlohmann::json;
int
main
()
{
// create a JSON null value
json
j
(
nullptr
);
// implicitly create a JSON null value
json
j1
;
// explicitly create a JSON null value
json
j2
(
nullptr
);
// serialize the JSON null value
std
::
cout
<<
j
<<
'\n'
;
std
::
cout
<<
j
1
<<
'\n'
<<
j2
<<
'\n'
;
}
doc/examples/basic_json__nullptr_t.link
View file @
442058f8
<a target="_blank" href="http://melpon.org/wandbox/permlink/PMMpoM0ujdJDsuta"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="http://melpon.org/wandbox/permlink/9Tvfs2dJBW8m8ihA"><b>online</b></a>
\ No newline at end of file
doc/examples/basic_json__nullptr_t.output
View file @
442058f8
null
null
src/json.hpp
View file @
442058f8
...
...
@@ -73,6 +73,15 @@ SOFTWARE.
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
// allow for portable deprecation warnings
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#define JSON_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define JSON_DEPRECATED __declspec(deprecated)
#else
#define JSON_DEPRECATED
#endif
/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
...
...
@@ -1057,40 +1066,10 @@ class basic_json
}
/*!
@brief create a null object (implicitly)
Create a `null` JSON value. This is the implicit version of the `null`
value constructor as it takes no parameters.
@note The class invariant is satisfied, because it poses no requirements
for null values.
@complexity Constant.
@exceptionsafety No-throw guarantee: this constructor never throws
exceptions.
@requirement This function helps `basic_json` satisfying the
[Container](http://en.cppreference.com/w/cpp/concept/Container)
requirements:
- The complexity is constant.
- As postcondition, it holds: `basic_json().empty() == true`.
@liveexample{The following code shows the constructor for a `null` JSON
value.,basic_json}
@sa @ref basic_json(std::nullptr_t) -- create a `null` value
@since version 1.0.0
*/
basic_json
()
=
default
;
/*!
@brief create a null object (explicitly)
@brief create a null object
Create a `null` JSON value. This is the explicitly version of the `null`
value constructor as it takes a null pointer as parameter. It allows to
create `null` values by explicitly assigning a `nullptr` to a JSON value.
Create a `null` JSON value. It either takes a null pointer as parameter
(explicitly creating `null`) or no parameter (implicitly creating `null`).
The passed null pointer itself is not read -- it is only used to choose
the right constructor.
...
...
@@ -1099,15 +1078,12 @@ class basic_json
@exceptionsafety No-throw guarantee: this constructor never throws
exceptions.
@liveexample{The following code shows the constructor with null pointer
parameter.,basic_json__nullptr_t}
@sa @ref basic_json() -- default constructor (implicitly creating a `null`
value)
@liveexample{The following code shows the constructor with and without a
null pointer parameter.,basic_json__nullptr_t}
@since version 1.0.0
*/
basic_json
(
std
::
nullptr_t
)
noexcept
basic_json
(
std
::
nullptr_t
=
nullptr
)
noexcept
:
basic_json
(
value_t
::
null
)
{
assert_invariant
();
...
...
@@ -1971,12 +1947,21 @@ class basic_json
@note A UTF-8 byte order mark is silently ignored.
@deprecated This constructor is deprecated and will be removed in version
3.0.0 to unify the interface of the library. Deserialization will be
done by stream operators or by calling one of the `parse` functions,
e.g. @ref parse(std::istream&, const parser_callback_t). That is, calls
like `json j(i);` for an input stream @a i need to be replaced by
`json j = json::parse(i);`. See the example below.
@liveexample{The example below demonstrates constructing a JSON value from
a `std::stringstream` with and without callback
function.,basic_json__istream}
@since version 2.0.0
@since version 2.0.0, deprecated in version 2.0.3, to be removed in
version 3.0.0
*/
JSON_DEPRECATED
explicit
basic_json
(
std
::
istream
&
i
,
const
parser_callback_t
cb
=
nullptr
)
{
*
this
=
parser
(
i
,
cb
).
parse
();
...
...
src/json.hpp.re2c
View file @
442058f8
...
...
@@ -73,6 +73,15 @@ SOFTWARE.
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
// allow for portable deprecation warnings
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#define JSON_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define JSON_DEPRECATED __declspec(deprecated)
#else
#define JSON_DEPRECATED
#endif
/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
...
...
@@ -1057,40 +1066,10 @@ class basic_json
}
/*!
@brief create a null object (implicitly)
Create a `null` JSON value. This is the implicit version of the `null`
value constructor as it takes no parameters.
@note The class invariant is satisfied, because it poses no requirements
for null values.
@complexity Constant.
@exceptionsafety No-throw guarantee: this constructor never throws
exceptions.
@requirement This function helps `basic_json` satisfying the
[Container](http://en.cppreference.com/w/cpp/concept/Container)
requirements:
- The complexity is constant.
- As postcondition, it holds: `basic_json().empty() == true`.
@liveexample{The following code shows the constructor for a `null` JSON
value.,basic_json}
@sa @ref basic_json(std::nullptr_t) -- create a `null` value
@since version 1.0.0
*/
basic_json() = default;
/*!
@brief create a null object (explicitly)
@brief create a null object
Create a `null` JSON value. This is the explicitly version of the `null`
value constructor as it takes a null pointer as parameter. It allows to
create `null` values by explicitly assigning a `nullptr` to a JSON value.
Create a `null` JSON value. It either takes a null pointer as parameter
(explicitly creating `null`) or no parameter (implicitly creating `null`).
The passed null pointer itself is not read -- it is only used to choose
the right constructor.
...
...
@@ -1099,15 +1078,12 @@ class basic_json
@exceptionsafety No-throw guarantee: this constructor never throws
exceptions.
@liveexample{The following code shows the constructor with null pointer
parameter.,basic_json__nullptr_t}
@sa @ref basic_json() -- default constructor (implicitly creating a `null`
value)
@liveexample{The following code shows the constructor with and without a
null pointer parameter.,basic_json__nullptr_t}
@since version 1.0.0
*/
basic_json(std::nullptr_t) noexcept
basic_json(std::nullptr_t
= nullptr
) noexcept
: basic_json(value_t::null)
{
assert_invariant();
...
...
@@ -1971,12 +1947,21 @@ class basic_json
@note A UTF-8 byte order mark is silently ignored.
@deprecated This constructor is deprecated and will be removed in version
3.0.0 to unify the interface of the library. Deserialization will be
done by stream operators or by calling one of the `parse` functions,
e.g. @ref parse(std::istream&, const parser_callback_t). That is, calls
like `json j(i);` for an input stream @a i need to be replaced by
`json j = json::parse(i);`. See the example below.
@liveexample{The example below demonstrates constructing a JSON value from
a `std::stringstream` with and without callback
function.,basic_json__istream}
@since version 2.0.0
@since version 2.0.0, deprecated in version 2.0.3, to be removed in
version 3.0.0
*/
JSON_DEPRECATED
explicit basic_json(std::istream& i, const parser_callback_t cb = nullptr)
{
*this = parser(i, cb).parse();
...
...
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