Deployed 6d4b72d3c with MkDocs version: 1.4.2
This commit is contained in:
1 parent
6a2266aff4
commit
5de3c82c9a
6 files changed
+241
-230
No files matched your search
@@ -1 +1 @@
|
||||
{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-\\.]"},"docs":[{"location":"","text":"JSON for Modern C++ \u00b6","title":"JSON for Modern C++"},{"location":"#json-for-modern-c","text":"","title":"JSON for Modern C++"},{"location":"api/json/","text":"nlohmann:: json \u00b6 using json = basic_json <> ; This type is the default specialization of the basic_json class which uses the standard template types. Examples \u00b6 Example The example below demonstrates how to use the type nlohmann::json . #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann :: json ; int main () { // create a JSON object json j = { { \"pi\" , 3.141 }, { \"happy\" , true }, { \"name\" , \"Niels\" }, { \"nothing\" , nullptr }, { \"answer\" , { { \"everything\" , 42 } } }, { \"list\" , { 1 , 0 , 2 }}, { \"object\" , { { \"currency\" , \"USD\" }, { \"value\" , 42.99 } } } }; // add new values j [ \"new\" ][ \"key\" ][ \"value\" ] = { \"another\" , \"list\" }; // count elements auto s = j . size (); j [ \"size\" ] = s ; // pretty print with indent of 4 spaces std :: cout << std :: setw ( 4 ) << j << '\\n' ; } Output: { \"answer\" : { \"everything\" : 42 }, \"happy\" : true , \"list\" : [ 1 , 0 , 2 ], \"name\" : \"Niels\" , \"new\" : { \"key\" : { \"value\" : [ \"another\" , \"list\" ] } }, \"nothing\" : null , \"object\" : { \"currency\" : \"USD\" , \"value\" : 42.99 }, \"pi\" : 3.141 , \"size\" : 8 } Version history \u00b6 Since version 1.0.0.","title":"json"},{"location":"api/json/#nlohmannjson","text":"using json = basic_json <> ; This type is the default specialization of the basic_json class which uses the standard template types.","title":"nlohmann::json"},{"location":"api/json/#examples","text":"Example The example below demonstrates how to use the type nlohmann::json . #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann :: json ; int main () { // create a JSON object json j = { { \"pi\" , 3.141 }, { \"happy\" , true }, { \"name\" , \"Niels\" }, { \"nothing\" , nullptr }, { \"answer\" , { { \"everything\" , 42 } } }, { \"list\" , { 1 , 0 , 2 }}, { \"object\" , { { \"currency\" , \"USD\" }, { \"value\" , 42.99 } } } }; // add new values j [ \"new\" ][ \"key\" ][ \"value\" ] = { \"another\" , \"list\" }; // count elements auto s = j . size (); j [ \"size\" ] = s ; // pretty print with indent of 4 spaces std :: cout << std :: setw ( 4 ) << j << '\\n' ; } Output: { \"answer\" : { \"everything\" : 42 }, \"happy\" : true , \"list\" : [ 1 , 0 , 2 ], \"name\" : \"Niels\" , \"new\" : { \"key\" : { \"value\" : [ \"another\" , \"list\" ] } }, \"nothing\" : null , \"object\" : { \"currency\" : \"USD\" , \"value\" : 42.99 }, \"pi\" : 3.141 , \"size\" : 8 }","title":"Examples"},{"location":"api/json/#version-history","text":"Since version 1.0.0.","title":"Version history"},{"location":"api/operator_gtgt/","text":"nlohmann:: operator>>(basic_json) \u00b6 std :: istream & operator >> ( std :: istream & i , basic_json & j ); Deserializes an input stream to a JSON value. Parameters \u00b6 i (in, out) input stream to read a serialized JSON value from j (in, out) JSON value to write the deserialized input to Return value \u00b6 the stream i Exceptions \u00b6 Throws parse_error.101 in case of an unexpected token. Throws parse_error.102 if to_unicode fails or surrogate error. Throws parse_error.103 if to_unicode fails. Complexity \u00b6 Linear in the length of the input. The parser is a predictive LL(1) parser. Notes \u00b6 A UTF-8 byte order mark is silently ignored. Deprecation This function replaces function std :: istream & operator << ( basic_json & j , std :: istream & i ) which has been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like j << i ; with i >> j ; . Examples \u00b6 Example The example below shows how a JSON value is constructed by reading a serialization from a stream. #include <iostream> #include <iomanip> #include <sstream> #include <nlohmann/json.hpp> using json = nlohmann :: json ; int main () { // create stream with serialized JSON std :: stringstream ss ; ss << R \" ( { \"number\": 23, \"string\": \"Hello, world!\", \"array\": [1, 2, 3, 4, 5], \"boolean\": false, \"null\": null } ) \" ; // create JSON value and read the serialization from the stream json j ; ss >> j ; // serialize JSON std :: cout << std :: setw ( 2 ) << j << '\\n' ; } Output: { \"array\" : [ 1 , 2 , 3 , 4 , 5 ], \"boolean\" : false , \"null\" : null , \"number\" : 23 , \"string\" : \"Hello, world!\" } See also \u00b6 accept - check if the input is valid JSON parse - deserialize from a compatible input Version history \u00b6 Added in version 1.0.0. Deprecated in version 3.0.0.","title":"operator>>(basic_json)"},{"location":"api/operator_gtgt/#nlohmannoperatorbasic_json","text":"std :: istream & operator >> ( std :: istream & i , basic_json & j ); Deserializes an input stream to a JSON valueLine truncated
|
||||
{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-\\.]"},"docs":[{"location":"","text":"JSON for Modern C++ \u00b6","title":"JSON for Modern C++"},{"location":"#json-for-modern-c","text":"","title":"JSON for Modern C++"},{"location":"api/json/","text":"nlohmann:: json \u00b6 using json = basic_json <> ; This type is the default specialization of the basic_json class which uses the standard template types. Examples \u00b6 Example The example below demonstrates how to use the type nlohmann::json . #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann :: json ; int main () { // create a JSON object json j = { { \"pi\" , 3.141 }, { \"happy\" , true }, { \"name\" , \"Niels\" }, { \"nothing\" , nullptr }, { \"answer\" , { { \"everything\" , 42 } } }, { \"list\" , { 1 , 0 , 2 }}, { \"object\" , { { \"currency\" , \"USD\" }, { \"value\" , 42.99 } } } }; // add new values j [ \"new\" ][ \"key\" ][ \"value\" ] = { \"another\" , \"list\" }; // count elements auto s = j . size (); j [ \"size\" ] = s ; // pretty print with indent of 4 spaces std :: cout << std :: setw ( 4 ) << j << '\\n' ; } Output: { \"answer\" : { \"everything\" : 42 }, \"happy\" : true , \"list\" : [ 1 , 0 , 2 ], \"name\" : \"Niels\" , \"new\" : { \"key\" : { \"value\" : [ \"another\" , \"list\" ] } }, \"nothing\" : null , \"object\" : { \"currency\" : \"USD\" , \"value\" : 42.99 }, \"pi\" : 3.141 , \"size\" : 8 } Version history \u00b6 Since version 1.0.0.","title":"json"},{"location":"api/json/#nlohmannjson","text":"using json = basic_json <> ; This type is the default specialization of the basic_json class which uses the standard template types.","title":"nlohmann::json"},{"location":"api/json/#examples","text":"Example The example below demonstrates how to use the type nlohmann::json . #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann :: json ; int main () { // create a JSON object json j = { { \"pi\" , 3.141 }, { \"happy\" , true }, { \"name\" , \"Niels\" }, { \"nothing\" , nullptr }, { \"answer\" , { { \"everything\" , 42 } } }, { \"list\" , { 1 , 0 , 2 }}, { \"object\" , { { \"currency\" , \"USD\" }, { \"value\" , 42.99 } } } }; // add new values j [ \"new\" ][ \"key\" ][ \"value\" ] = { \"another\" , \"list\" }; // count elements auto s = j . size (); j [ \"size\" ] = s ; // pretty print with indent of 4 spaces std :: cout << std :: setw ( 4 ) << j << '\\n' ; } Output: { \"answer\" : { \"everything\" : 42 }, \"happy\" : true , \"list\" : [ 1 , 0 , 2 ], \"name\" : \"Niels\" , \"new\" : { \"key\" : { \"value\" : [ \"another\" , \"list\" ] } }, \"nothing\" : null , \"object\" : { \"currency\" : \"USD\" , \"value\" : 42.99 }, \"pi\" : 3.141 , \"size\" : 8 }","title":"Examples"},{"location":"api/json/#version-history","text":"Since version 1.0.0.","title":"Version history"},{"location":"api/operator_gtgt/","text":"nlohmann:: operator>>(basic_json) \u00b6 std :: istream & operator >> ( std :: istream & i , basic_json & j ); Deserializes an input stream to a JSON value. Parameters \u00b6 i (in, out) input stream to read a serialized JSON value from j (in, out) JSON value to write the deserialized input to Return value \u00b6 the stream i Exceptions \u00b6 Throws parse_error.101 in case of an unexpected token. Throws parse_error.102 if to_unicode fails or surrogate error. Throws parse_error.103 if to_unicode fails. Complexity \u00b6 Linear in the length of the input. The parser is a predictive LL(1) parser. Notes \u00b6 A UTF-8 byte order mark is silently ignored. Deprecation This function replaces function std :: istream & operator << ( basic_json & j , std :: istream & i ) which has been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like j << i ; with i >> j ; . Examples \u00b6 Example The example below shows how a JSON value is constructed by reading a serialization from a stream. #include <iostream> #include <iomanip> #include <sstream> #include <nlohmann/json.hpp> using json = nlohmann :: json ; int main () { // create stream with serialized JSON std :: stringstream ss ; ss << R \" ( { \"number\": 23, \"string\": \"Hello, world!\", \"array\": [1, 2, 3, 4, 5], \"boolean\": false, \"null\": null } ) \" ; // create JSON value and read the serialization from the stream json j ; ss >> j ; // serialize JSON std :: cout << std :: setw ( 2 ) << j << '\\n' ; } Output: { \"array\" : [ 1 , 2 , 3 , 4 , 5 ], \"boolean\" : false , \"null\" : null , \"number\" : 23 , \"string\" : \"Hello, world!\" } See also \u00b6 accept - check if the input is valid JSON parse - deserialize from a compatible input Version history \u00b6 Added in version 1.0.0. Deprecated in version 3.0.0.","title":"operator>>(basic_json)"},{"location":"api/operator_gtgt/#nlohmannoperatorbasic_json","text":"std :: istream & operator >> ( std :: istream & i , basic_json & j ); Deserializes an input stream to a JSON valueLine truncated
|
||||
Reference in new issue
Block a user