JSON for Modern C++  2.0.3
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
template<class T , std::size_t N>
static basic_json nlohmann::basic_json::parse ( T(&)  array[N],
const parser_callback_t  cb = nullptr 
)
inlinestatic

This function reads from an array of 1-byte values.

Precondition
Each element of the container has a size of 1 byte. Violating this precondition yields undefined behavior. This precondition is enforced with a static assertion.
Parameters
[in]arrayarray to read from
[in]cba parser callback function of type parser_callback_t which is used to control the deserialization by filtering unwanted values (optional)
Returns
result of the deserialization
Complexity
Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser callback function cb has a super-linear complexity.
Note
A UTF-8 byte order mark is silently ignored.
Example
The example below demonstrates the parse() function reading from an array.
1 #include <json.hpp>
2 
3 using json = nlohmann::json;
4 
5 int main()
6 {
7  // a JSON text
8  char text[] = R"(
9  {
10  "Image": {
11  "Width": 800,
12  "Height": 600,
13  "Title": "View from 15th Floor",
14  "Thumbnail": {
15  "Url": "http://www.example.com/image/481989943",
16  "Height": 125,
17  "Width": 100
18  },
19  "Animated" : false,
20  "IDs": [116, 943, 234, 38793]
21  }
22  }
23  )";
24 
25  // parse and serialize JSON
26  json j_complete = json::parse(text);
27  std::cout << std::setw(4) << j_complete << "\n\n";
28 }
basic_json<> json
default JSON class
Definition: json.hpp:10122
static basic_json parse(T(&array)[N], const parser_callback_t cb=nullptr)
deserialize from an array
Definition: json.hpp:5893
Output (play with this example online):
{
    "Image": {
        "Animated": false,
        "Height": 600,
        "IDs": [
            116,
            943,
            234,
            38793
        ],
        "Thumbnail": {
            "Height": 125,
            "Url": "http://www.example.com/image/481989943",
            "Width": 100
        },
        "Title": "View from 15th Floor",
        "Width": 800
    }
}

The example code above can be translated with
g++ -std=c++11 -Isrc doc/examples/parse__array__parser_callback_t.cpp -o parse__array__parser_callback_t 
Since
version 2.0.3

Definition at line 5893 of file json.hpp.