Q: problem reading json string with minijson-reader library While trying parsing a json string in my c++ code, using the library minijson, I got a code like that so far:
    <<"version">> [&]() { result.setVersion(v.as_long()); }
    <<"capabilities">> [&]()
    {
        parse_array(ctx, [&](value capability)
        {
            result.getCapabilities().push_back(capability.as_string());
        });
    }

the data should be stored on this struct:
struct block_template {
  int version;
  vector<string> capabilities;
  ...
}

the version value is stored correctly, but the vector is staying with size 0. I try visualize the data being read from the json string ( with cout << capability.as_string() << endl ) and it's display correctly, just not being stored in the data structure.
Anyone who already worked with this library can give a hint of what's wrong here?

A: Since the OP asks for examples using other libraries in the comments, I'll reply more generally.
In jsoncons, if the JSON member names and the C++ variable names were the same, you could use the macro JSONCONS_ALL_MEMBER_TRAITS to set up the mappings,
#include <iostream>
#include <jsoncons/json.hpp>

struct block_template {
  int version;
  std::vector<std::string> capabilities;
};

JSONCONS_ALL_MEMBER_TRAITS(block_template, version, capabilities)

int main()
{
    std::string input = R"(
    {
        "version" : 1,
        "capabilities" : ["foo","bar","baz"]
    }
    )";

    auto result = jsoncons::decode_json<block_template>(input);

    std::cout << "(1)\n" << "version: " << val.version << "\n";
    for (auto& item : val.capabilities)
    {
        std::cout << "item: " << item << "\n";
    }

    std::string output;
    jsoncons::encode_json(val, output, jsoncons::indenting::indent);
    std::cout << "(2)\n" << output << "\n\n";
}

Output:
(1)
version: 1
item: foo
item: bar
item: baz
(2)
{
    "capabilities": ["foo", "bar", "baz"],
    "version": 1
}

And if the JSON and C++ names were different, you could use the macro JSONCONS_ALL_MEMBER_NAME_TRAITS instead,
JSONCONS_ALL_MEMBER_NAME_TRAITS(block_template, (version,"Version"), 
                                (capabilities,"Capabilities"))

With this change, the output becomes:
(1)
version: 1
item: foo
item: bar
item: baz
(2)
{
    "Capabilities": ["foo", "bar", "baz"],
    "Version": 1
}

See this answer for more examples of libraries that decode JSON to C++ data structures and encode back again, including Martin York's interesting ThorsSerializer.
