No version for distro humble showing github. Known supported distros are highlighted in the buttons above.
Package symbol

json_struct package from json_struct repo

json_struct

ROS Distro
github

Package Summary

Tags No category tags.
Version 0.0.1
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Description json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Checkout URI https://github.com/jorgen/json_struct.git
VCS Type git
VCS Version master
Last Updated 2025-06-10
Dev Status UNKNOWN
Released UNRELEASED
Tags c-plus-plus serialization json parse deserialization template-metaprogramming template-specialisations
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Package Description

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

Additional Links

No additional links.

Maintainers

  • Jørgen Lind

Authors

No additional authors.

Structurize your JSON

Build status ClusterFuzzLite PR fuzzing

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

It is intended to be used by copying the json_struct.h file from the include folder into the include path for the project. It is only the json_struct.h file that is needed to serialize and deserialize json from structures.

It is dependent on some C++11 features and is tested on newer versions of gcc and clang. It is also tested on VS 2015 and newer.

Structs

json_struct can parse JSON and automatically populate structures with content by adding some metadata to the C++ structs.

{
    "One" : 1,
    "Two" : "two",
    "Three" : 3.333
}

can be parsed into a structure defined like this:

struct JsonObject
{
    int One;
    std::string Two;
    double Three;

    JS_OBJ(One, Two, Three);
};

or

struct JsonObject
{
    int One;
    std::string Two;
    double Three;
};
JS_OBJ_EXT(JsonObject, One, Two, Three);

Populating the struct would look like this:

JS::ParseContext context(json_data);
JsonObject obj;
context.parseTo(obj);

Serializing the struct to json could be done like this:

std::string pretty_json = JS::serializeStruct(obj);
// or
std::string compact_json = JS::serializeStruct(obj, JS::SerializerOptions(JS::SerializerOptions::Compact));

Maps

Sometimes the structure of the JSON is dependent on some value in the JSON. Say there is some input JSON that describes a transportation vehicle. It can looks something like this

{
  "type" : "car",
  "wheels" : 4,
  "electric" : true,
...
}

or it could look like this:

{
  "type" : "sailboat",
  "sail_area_m2" : 106.5,
  "swimming_platform": true,
...
}

This doesn’t fit well with the static nature of json_struct. However, it is possible to parse the JSON into a map structure, query some child members for data and then dispatch the conversion into an appropriate type.

```c++ void handle_data(const char *data, size_t size) { JS::Map map; JS::ParseContext parseContext(data, size, map);

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged json_struct at Robotics Stack Exchange

No version for distro jazzy showing github. Known supported distros are highlighted in the buttons above.
Package symbol

json_struct package from json_struct repo

json_struct

ROS Distro
github

Package Summary

Tags No category tags.
Version 0.0.1
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Description json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Checkout URI https://github.com/jorgen/json_struct.git
VCS Type git
VCS Version master
Last Updated 2025-06-10
Dev Status UNKNOWN
Released UNRELEASED
Tags c-plus-plus serialization json parse deserialization template-metaprogramming template-specialisations
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Package Description

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

Additional Links

No additional links.

Maintainers

  • Jørgen Lind

Authors

No additional authors.

Structurize your JSON

Build status ClusterFuzzLite PR fuzzing

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

It is intended to be used by copying the json_struct.h file from the include folder into the include path for the project. It is only the json_struct.h file that is needed to serialize and deserialize json from structures.

It is dependent on some C++11 features and is tested on newer versions of gcc and clang. It is also tested on VS 2015 and newer.

Structs

json_struct can parse JSON and automatically populate structures with content by adding some metadata to the C++ structs.

{
    "One" : 1,
    "Two" : "two",
    "Three" : 3.333
}

can be parsed into a structure defined like this:

struct JsonObject
{
    int One;
    std::string Two;
    double Three;

    JS_OBJ(One, Two, Three);
};

or

struct JsonObject
{
    int One;
    std::string Two;
    double Three;
};
JS_OBJ_EXT(JsonObject, One, Two, Three);

Populating the struct would look like this:

JS::ParseContext context(json_data);
JsonObject obj;
context.parseTo(obj);

Serializing the struct to json could be done like this:

std::string pretty_json = JS::serializeStruct(obj);
// or
std::string compact_json = JS::serializeStruct(obj, JS::SerializerOptions(JS::SerializerOptions::Compact));

Maps

Sometimes the structure of the JSON is dependent on some value in the JSON. Say there is some input JSON that describes a transportation vehicle. It can looks something like this

{
  "type" : "car",
  "wheels" : 4,
  "electric" : true,
...
}

or it could look like this:

{
  "type" : "sailboat",
  "sail_area_m2" : 106.5,
  "swimming_platform": true,
...
}

This doesn’t fit well with the static nature of json_struct. However, it is possible to parse the JSON into a map structure, query some child members for data and then dispatch the conversion into an appropriate type.

```c++ void handle_data(const char *data, size_t size) { JS::Map map; JS::ParseContext parseContext(data, size, map);

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged json_struct at Robotics Stack Exchange

No version for distro kilted showing github. Known supported distros are highlighted in the buttons above.
Package symbol

json_struct package from json_struct repo

json_struct

ROS Distro
github

Package Summary

Tags No category tags.
Version 0.0.1
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Description json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Checkout URI https://github.com/jorgen/json_struct.git
VCS Type git
VCS Version master
Last Updated 2025-06-10
Dev Status UNKNOWN
Released UNRELEASED
Tags c-plus-plus serialization json parse deserialization template-metaprogramming template-specialisations
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Package Description

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

Additional Links

No additional links.

Maintainers

  • Jørgen Lind

Authors

No additional authors.

Structurize your JSON

Build status ClusterFuzzLite PR fuzzing

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

It is intended to be used by copying the json_struct.h file from the include folder into the include path for the project. It is only the json_struct.h file that is needed to serialize and deserialize json from structures.

It is dependent on some C++11 features and is tested on newer versions of gcc and clang. It is also tested on VS 2015 and newer.

Structs

json_struct can parse JSON and automatically populate structures with content by adding some metadata to the C++ structs.

{
    "One" : 1,
    "Two" : "two",
    "Three" : 3.333
}

can be parsed into a structure defined like this:

struct JsonObject
{
    int One;
    std::string Two;
    double Three;

    JS_OBJ(One, Two, Three);
};

or

struct JsonObject
{
    int One;
    std::string Two;
    double Three;
};
JS_OBJ_EXT(JsonObject, One, Two, Three);

Populating the struct would look like this:

JS::ParseContext context(json_data);
JsonObject obj;
context.parseTo(obj);

Serializing the struct to json could be done like this:

std::string pretty_json = JS::serializeStruct(obj);
// or
std::string compact_json = JS::serializeStruct(obj, JS::SerializerOptions(JS::SerializerOptions::Compact));

Maps

Sometimes the structure of the JSON is dependent on some value in the JSON. Say there is some input JSON that describes a transportation vehicle. It can looks something like this

{
  "type" : "car",
  "wheels" : 4,
  "electric" : true,
...
}

or it could look like this:

{
  "type" : "sailboat",
  "sail_area_m2" : 106.5,
  "swimming_platform": true,
...
}

This doesn’t fit well with the static nature of json_struct. However, it is possible to parse the JSON into a map structure, query some child members for data and then dispatch the conversion into an appropriate type.

```c++ void handle_data(const char *data, size_t size) { JS::Map map; JS::ParseContext parseContext(data, size, map);

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged json_struct at Robotics Stack Exchange

No version for distro rolling showing github. Known supported distros are highlighted in the buttons above.
Package symbol

json_struct package from json_struct repo

json_struct

ROS Distro
github

Package Summary

Tags No category tags.
Version 0.0.1
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Description json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Checkout URI https://github.com/jorgen/json_struct.git
VCS Type git
VCS Version master
Last Updated 2025-06-10
Dev Status UNKNOWN
Released UNRELEASED
Tags c-plus-plus serialization json parse deserialization template-metaprogramming template-specialisations
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Package Description

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

Additional Links

No additional links.

Maintainers

  • Jørgen Lind

Authors

No additional authors.

Structurize your JSON

Build status ClusterFuzzLite PR fuzzing

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

It is intended to be used by copying the json_struct.h file from the include folder into the include path for the project. It is only the json_struct.h file that is needed to serialize and deserialize json from structures.

It is dependent on some C++11 features and is tested on newer versions of gcc and clang. It is also tested on VS 2015 and newer.

Structs

json_struct can parse JSON and automatically populate structures with content by adding some metadata to the C++ structs.

{
    "One" : 1,
    "Two" : "two",
    "Three" : 3.333
}

can be parsed into a structure defined like this:

struct JsonObject
{
    int One;
    std::string Two;
    double Three;

    JS_OBJ(One, Two, Three);
};

or

struct JsonObject
{
    int One;
    std::string Two;
    double Three;
};
JS_OBJ_EXT(JsonObject, One, Two, Three);

Populating the struct would look like this:

JS::ParseContext context(json_data);
JsonObject obj;
context.parseTo(obj);

Serializing the struct to json could be done like this:

std::string pretty_json = JS::serializeStruct(obj);
// or
std::string compact_json = JS::serializeStruct(obj, JS::SerializerOptions(JS::SerializerOptions::Compact));

Maps

Sometimes the structure of the JSON is dependent on some value in the JSON. Say there is some input JSON that describes a transportation vehicle. It can looks something like this

{
  "type" : "car",
  "wheels" : 4,
  "electric" : true,
...
}

or it could look like this:

{
  "type" : "sailboat",
  "sail_area_m2" : 106.5,
  "swimming_platform": true,
...
}

This doesn’t fit well with the static nature of json_struct. However, it is possible to parse the JSON into a map structure, query some child members for data and then dispatch the conversion into an appropriate type.

```c++ void handle_data(const char *data, size_t size) { JS::Map map; JS::ParseContext parseContext(data, size, map);

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged json_struct at Robotics Stack Exchange

Package symbol

json_struct package from json_struct repo

json_struct

ROS Distro
github

Package Summary

Tags No category tags.
Version 0.0.1
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Description json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Checkout URI https://github.com/jorgen/json_struct.git
VCS Type git
VCS Version master
Last Updated 2025-06-10
Dev Status UNKNOWN
Released UNRELEASED
Tags c-plus-plus serialization json parse deserialization template-metaprogramming template-specialisations
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Package Description

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

Additional Links

No additional links.

Maintainers

  • Jørgen Lind

Authors

No additional authors.

Structurize your JSON

Build status ClusterFuzzLite PR fuzzing

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

It is intended to be used by copying the json_struct.h file from the include folder into the include path for the project. It is only the json_struct.h file that is needed to serialize and deserialize json from structures.

It is dependent on some C++11 features and is tested on newer versions of gcc and clang. It is also tested on VS 2015 and newer.

Structs

json_struct can parse JSON and automatically populate structures with content by adding some metadata to the C++ structs.

{
    "One" : 1,
    "Two" : "two",
    "Three" : 3.333
}

can be parsed into a structure defined like this:

struct JsonObject
{
    int One;
    std::string Two;
    double Three;

    JS_OBJ(One, Two, Three);
};

or

struct JsonObject
{
    int One;
    std::string Two;
    double Three;
};
JS_OBJ_EXT(JsonObject, One, Two, Three);

Populating the struct would look like this:

JS::ParseContext context(json_data);
JsonObject obj;
context.parseTo(obj);

Serializing the struct to json could be done like this:

std::string pretty_json = JS::serializeStruct(obj);
// or
std::string compact_json = JS::serializeStruct(obj, JS::SerializerOptions(JS::SerializerOptions::Compact));

Maps

Sometimes the structure of the JSON is dependent on some value in the JSON. Say there is some input JSON that describes a transportation vehicle. It can looks something like this

{
  "type" : "car",
  "wheels" : 4,
  "electric" : true,
...
}

or it could look like this:

{
  "type" : "sailboat",
  "sail_area_m2" : 106.5,
  "swimming_platform": true,
...
}

This doesn’t fit well with the static nature of json_struct. However, it is possible to parse the JSON into a map structure, query some child members for data and then dispatch the conversion into an appropriate type.

```c++ void handle_data(const char *data, size_t size) { JS::Map map; JS::ParseContext parseContext(data, size, map);

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged json_struct at Robotics Stack Exchange

No version for distro galactic showing github. Known supported distros are highlighted in the buttons above.
Package symbol

json_struct package from json_struct repo

json_struct

ROS Distro
github

Package Summary

Tags No category tags.
Version 0.0.1
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Description json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Checkout URI https://github.com/jorgen/json_struct.git
VCS Type git
VCS Version master
Last Updated 2025-06-10
Dev Status UNKNOWN
Released UNRELEASED
Tags c-plus-plus serialization json parse deserialization template-metaprogramming template-specialisations
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Package Description

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

Additional Links

No additional links.

Maintainers

  • Jørgen Lind

Authors

No additional authors.

Structurize your JSON

Build status ClusterFuzzLite PR fuzzing

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

It is intended to be used by copying the json_struct.h file from the include folder into the include path for the project. It is only the json_struct.h file that is needed to serialize and deserialize json from structures.

It is dependent on some C++11 features and is tested on newer versions of gcc and clang. It is also tested on VS 2015 and newer.

Structs

json_struct can parse JSON and automatically populate structures with content by adding some metadata to the C++ structs.

{
    "One" : 1,
    "Two" : "two",
    "Three" : 3.333
}

can be parsed into a structure defined like this:

struct JsonObject
{
    int One;
    std::string Two;
    double Three;

    JS_OBJ(One, Two, Three);
};

or

struct JsonObject
{
    int One;
    std::string Two;
    double Three;
};
JS_OBJ_EXT(JsonObject, One, Two, Three);

Populating the struct would look like this:

JS::ParseContext context(json_data);
JsonObject obj;
context.parseTo(obj);

Serializing the struct to json could be done like this:

std::string pretty_json = JS::serializeStruct(obj);
// or
std::string compact_json = JS::serializeStruct(obj, JS::SerializerOptions(JS::SerializerOptions::Compact));

Maps

Sometimes the structure of the JSON is dependent on some value in the JSON. Say there is some input JSON that describes a transportation vehicle. It can looks something like this

{
  "type" : "car",
  "wheels" : 4,
  "electric" : true,
...
}

or it could look like this:

{
  "type" : "sailboat",
  "sail_area_m2" : 106.5,
  "swimming_platform": true,
...
}

This doesn’t fit well with the static nature of json_struct. However, it is possible to parse the JSON into a map structure, query some child members for data and then dispatch the conversion into an appropriate type.

```c++ void handle_data(const char *data, size_t size) { JS::Map map; JS::ParseContext parseContext(data, size, map);

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged json_struct at Robotics Stack Exchange

No version for distro iron showing github. Known supported distros are highlighted in the buttons above.
Package symbol

json_struct package from json_struct repo

json_struct

ROS Distro
github

Package Summary

Tags No category tags.
Version 0.0.1
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Description json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Checkout URI https://github.com/jorgen/json_struct.git
VCS Type git
VCS Version master
Last Updated 2025-06-10
Dev Status UNKNOWN
Released UNRELEASED
Tags c-plus-plus serialization json parse deserialization template-metaprogramming template-specialisations
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Package Description

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

Additional Links

No additional links.

Maintainers

  • Jørgen Lind

Authors

No additional authors.

Structurize your JSON

Build status ClusterFuzzLite PR fuzzing

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

It is intended to be used by copying the json_struct.h file from the include folder into the include path for the project. It is only the json_struct.h file that is needed to serialize and deserialize json from structures.

It is dependent on some C++11 features and is tested on newer versions of gcc and clang. It is also tested on VS 2015 and newer.

Structs

json_struct can parse JSON and automatically populate structures with content by adding some metadata to the C++ structs.

{
    "One" : 1,
    "Two" : "two",
    "Three" : 3.333
}

can be parsed into a structure defined like this:

struct JsonObject
{
    int One;
    std::string Two;
    double Three;

    JS_OBJ(One, Two, Three);
};

or

struct JsonObject
{
    int One;
    std::string Two;
    double Three;
};
JS_OBJ_EXT(JsonObject, One, Two, Three);

Populating the struct would look like this:

JS::ParseContext context(json_data);
JsonObject obj;
context.parseTo(obj);

Serializing the struct to json could be done like this:

std::string pretty_json = JS::serializeStruct(obj);
// or
std::string compact_json = JS::serializeStruct(obj, JS::SerializerOptions(JS::SerializerOptions::Compact));

Maps

Sometimes the structure of the JSON is dependent on some value in the JSON. Say there is some input JSON that describes a transportation vehicle. It can looks something like this

{
  "type" : "car",
  "wheels" : 4,
  "electric" : true,
...
}

or it could look like this:

{
  "type" : "sailboat",
  "sail_area_m2" : 106.5,
  "swimming_platform": true,
...
}

This doesn’t fit well with the static nature of json_struct. However, it is possible to parse the JSON into a map structure, query some child members for data and then dispatch the conversion into an appropriate type.

```c++ void handle_data(const char *data, size_t size) { JS::Map map; JS::ParseContext parseContext(data, size, map);

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged json_struct at Robotics Stack Exchange

No version for distro melodic showing github. Known supported distros are highlighted in the buttons above.
Package symbol

json_struct package from json_struct repo

json_struct

ROS Distro
github

Package Summary

Tags No category tags.
Version 0.0.1
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Description json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Checkout URI https://github.com/jorgen/json_struct.git
VCS Type git
VCS Version master
Last Updated 2025-06-10
Dev Status UNKNOWN
Released UNRELEASED
Tags c-plus-plus serialization json parse deserialization template-metaprogramming template-specialisations
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Package Description

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

Additional Links

No additional links.

Maintainers

  • Jørgen Lind

Authors

No additional authors.

Structurize your JSON

Build status ClusterFuzzLite PR fuzzing

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

It is intended to be used by copying the json_struct.h file from the include folder into the include path for the project. It is only the json_struct.h file that is needed to serialize and deserialize json from structures.

It is dependent on some C++11 features and is tested on newer versions of gcc and clang. It is also tested on VS 2015 and newer.

Structs

json_struct can parse JSON and automatically populate structures with content by adding some metadata to the C++ structs.

{
    "One" : 1,
    "Two" : "two",
    "Three" : 3.333
}

can be parsed into a structure defined like this:

struct JsonObject
{
    int One;
    std::string Two;
    double Three;

    JS_OBJ(One, Two, Three);
};

or

struct JsonObject
{
    int One;
    std::string Two;
    double Three;
};
JS_OBJ_EXT(JsonObject, One, Two, Three);

Populating the struct would look like this:

JS::ParseContext context(json_data);
JsonObject obj;
context.parseTo(obj);

Serializing the struct to json could be done like this:

std::string pretty_json = JS::serializeStruct(obj);
// or
std::string compact_json = JS::serializeStruct(obj, JS::SerializerOptions(JS::SerializerOptions::Compact));

Maps

Sometimes the structure of the JSON is dependent on some value in the JSON. Say there is some input JSON that describes a transportation vehicle. It can looks something like this

{
  "type" : "car",
  "wheels" : 4,
  "electric" : true,
...
}

or it could look like this:

{
  "type" : "sailboat",
  "sail_area_m2" : 106.5,
  "swimming_platform": true,
...
}

This doesn’t fit well with the static nature of json_struct. However, it is possible to parse the JSON into a map structure, query some child members for data and then dispatch the conversion into an appropriate type.

```c++ void handle_data(const char *data, size_t size) { JS::Map map; JS::ParseContext parseContext(data, size, map);

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged json_struct at Robotics Stack Exchange

No version for distro noetic showing github. Known supported distros are highlighted in the buttons above.
Package symbol

json_struct package from json_struct repo

json_struct

ROS Distro
github

Package Summary

Tags No category tags.
Version 0.0.1
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Description json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Checkout URI https://github.com/jorgen/json_struct.git
VCS Type git
VCS Version master
Last Updated 2025-06-10
Dev Status UNKNOWN
Released UNRELEASED
Tags c-plus-plus serialization json parse deserialization template-metaprogramming template-specialisations
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Package Description

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

Additional Links

No additional links.

Maintainers

  • Jørgen Lind

Authors

No additional authors.

Structurize your JSON

Build status ClusterFuzzLite PR fuzzing

json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON.

It is intended to be used by copying the json_struct.h file from the include folder into the include path for the project. It is only the json_struct.h file that is needed to serialize and deserialize json from structures.

It is dependent on some C++11 features and is tested on newer versions of gcc and clang. It is also tested on VS 2015 and newer.

Structs

json_struct can parse JSON and automatically populate structures with content by adding some metadata to the C++ structs.

{
    "One" : 1,
    "Two" : "two",
    "Three" : 3.333
}

can be parsed into a structure defined like this:

struct JsonObject
{
    int One;
    std::string Two;
    double Three;

    JS_OBJ(One, Two, Three);
};

or

struct JsonObject
{
    int One;
    std::string Two;
    double Three;
};
JS_OBJ_EXT(JsonObject, One, Two, Three);

Populating the struct would look like this:

JS::ParseContext context(json_data);
JsonObject obj;
context.parseTo(obj);

Serializing the struct to json could be done like this:

std::string pretty_json = JS::serializeStruct(obj);
// or
std::string compact_json = JS::serializeStruct(obj, JS::SerializerOptions(JS::SerializerOptions::Compact));

Maps

Sometimes the structure of the JSON is dependent on some value in the JSON. Say there is some input JSON that describes a transportation vehicle. It can looks something like this

{
  "type" : "car",
  "wheels" : 4,
  "electric" : true,
...
}

or it could look like this:

{
  "type" : "sailboat",
  "sail_area_m2" : 106.5,
  "swimming_platform": true,
...
}

This doesn’t fit well with the static nature of json_struct. However, it is possible to parse the JSON into a map structure, query some child members for data and then dispatch the conversion into an appropriate type.

```c++ void handle_data(const char *data, size_t size) { JS::Map map; JS::ParseContext parseContext(data, size, map);

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged json_struct at Robotics Stack Exchange