Questions tagged [boost-json]
18 questions
2
votes
2 answers
C++ How to check if json key exists using boost::json::value?
Using boost::json::value, how do I check if a certain key exists?
The following code:
void checkMessage(std::string msg)
{
boost::json::value json = boost::json::parse(payload);
auto type = json.at("type").as_string();
auto param1 =…

Mendes
- 17,489
- 35
- 150
- 263
2
votes
1 answer
How to mate std::chrono::minutes to boost::json tag_invoke value_from?
I try to store/load std::chrono::minutes to/from json using boost::jsons tag_invoke mechanism. While this works well for my custom little struct, I fail to formulate correct syntax for the chrono type.
I tried two straightforward versions:
void…

kaba
- 362
- 1
- 13
2
votes
1 answer
How to convert a struct that includes an enum member to JSON with Boost Describe?
In the documentation of Boost Describe, there is an example for automatic conversion of a struct to JSON. However, when adding an enum (not a nested one) as a member of the struct, the code example does not work. I guess that the tag_invoke function…

Koija
- 35
- 4
2
votes
1 answer
How to call a parameterless function using boost::json::value
I'm modifying from here code:
#include
#include
#include
#include
#include
#include
#include…

Kargath
- 450
- 5
- 15
2
votes
3 answers
How to use Boost/Json on linux
I have used boost/json inside my C++ project which I have created under windows. There the dependency was installed with vcpkg (vcpkg.exe install boost-json). Now I want to port this project to Ubuntu. But I have no clue how to install the library…

sebwr
- 113
- 1
- 10
1
vote
1 answer
Boost Json conversion error for array of custom object
I'm trying to code a simple json to struct (and back) conversion by using tag_invoke overload of boost::json lib.
Those are my structs:
template
void extract( boost::json::object const& obj, T& t, boost::json::string_view key )
{
t =…

hirish
- 188
- 9
1
vote
1 answer
How to convert a struct that includes a pointer member to JSON with Boost Describe
In the documentation of Boost Describe, there is an example for automatic conversion of a struct to JSON (https://www.boost.org/doc/libs/1_78_0/libs/describe/doc/html/describe.html#example_to_json). However, when adding a pointer as a member of the…

Koija
- 35
- 4
1
vote
1 answer
Override std::tuple serializing functionality in boost::json
boost::json::tag_invoke works fine with structs, but is totally ignored with std::tuple.
Look the next example and mind how the two json arrays are diferent:
Coliru link: https://coliru.stacked-crooked.com/a/e8689f9c523cee2a
#include…

Pablo
- 557
- 3
- 16
1
vote
1 answer
Could not find a package configuration file provided by "boost_json"
While following this link to setup boost for json parsing, I am unable to find the boost json component.
Link:
Using boost::json static library with cmake
Here's my CMakeLists.txt:
cmake_minimum_required(VERSION 3.9)
set (CMAKE_CXX_STANDARD…

Vineet Dwivedi
- 57
- 7
1
vote
1 answer
BOOST_DEFINE_ENUM_CLASS and json
In the documentation for boost describe, under the heading "Automatic Conversion to JSON", it shows how to implement "a universal tag_invoke overload that automatically converts an annotated struct to a Boost.JSON value". The example supports…

ixitzachitl
- 85
- 6
1
vote
2 answers
Have any one tried building Boost.Json static library?
I am trying to build boost json to get libboost_json.a .
tried using --with-json option but it never generates .
my config says its building , but I do not see this lib getting generated ,
enter image description here

Rajeev
- 19
- 1
1
vote
1 answer
Class cannot serialize itself using boost::json
I wrote a tiny class which relies on boost::json to serialize itself.
It fails to compile since compiler sounds to fail finding tag_invoke() functions which implement json::value<=>myClass translation :
/usr/include/boost/json/value_from.hpp:87:35:…

sylwa06
- 77
- 10
0
votes
1 answer
C++ boost ptree segmentation fault in multiplayer server with Unity client
I am building a complete multiplayer application with 2 servers of nodejs and C++, the problem in the C++ server is that as soon as a client from the Unity client connects and sends the userdata, the server has a segmentation fault and exits without…
0
votes
0 answers
boost::json constraint with including in one and only one .cpp
I am getting linking 2005 errors when using standalone boost:json in two different .cpp files in my MFC project.
I understand the constraints, but I wonder is there is any change to get rid of it.
The two instances of those classes are not related…

Pablo
- 557
- 3
- 16
0
votes
0 answers
Effective replacement for at_pointer() function with Boost-Json 1.75
I am searching for an effective way to access to deeply nested element in JSON.
Let's say:
{
"parent": [
0,
{
"child": "nested elem"
},
"string"
]
}
I want to access to the "nested element" with a JSON pointer/url :…

Moulagaufres
- 33
- 6