All Projects → P-i-N → json5

P-i-N / json5

Licence: MIT license
Header only JSON/JSON5 parser and serializer for C++

Programming Languages

C++
36643 projects - #6 most used programming language
lua
6591 projects

Projects that are alternatives of or similar to json5

BinaryLove3
Simple C++ 20 Serialization Library that works out of the box with aggregate types!
Stars: ✭ 13 (-40.91%)
Mutual labels:  serialization, cpp20
opzioni
The wanna-be-simplest command line arguments library for C++
Stars: ✭ 29 (+31.82%)
Mutual labels:  cpp20
Eden
edn (extensible data notation) encoder/decoder for Elixir
Stars: ✭ 32 (+45.45%)
Mutual labels:  serialization
gal
Geometric Algebra Library
Stars: ✭ 78 (+254.55%)
Mutual labels:  cpp20
jim
Immediate Mode JSON Serialization Library in C
Stars: ✭ 35 (+59.09%)
Mutual labels:  serialization
bytes
Work with bytes and implement network protocols
Stars: ✭ 77 (+250%)
Mutual labels:  serialization
yserial
NoSQL y_serial Python module – warehouse compressed objects with SQLite
Stars: ✭ 17 (-22.73%)
Mutual labels:  serialization
sexpresso
An s-expression library for C++
Stars: ✭ 41 (+86.36%)
Mutual labels:  serialization
json struct
json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Stars: ✭ 279 (+1168.18%)
Mutual labels:  serialization
BackportCpp
Library of backported modern C++ types to work with C++11
Stars: ✭ 53 (+140.91%)
Mutual labels:  cpp20
edap
No description or website provided.
Stars: ✭ 22 (+0%)
Mutual labels:  serialization
Json-to-Dart-Model
marketplace.visualstudio.com/items?itemName=hirantha.json-to-dart
Stars: ✭ 84 (+281.82%)
Mutual labels:  serialization
break-fast-serial
A proof of concept that demonstrates asynchronous scanning for Java deserialization bugs
Stars: ✭ 53 (+140.91%)
Mutual labels:  serialization
har-rs
A HTTP Archive format (HAR) serialization & deserialization library, written in Rust.
Stars: ✭ 25 (+13.64%)
Mutual labels:  serialization
HTTP-Wrapper
A simple http wrapper
Stars: ✭ 13 (-40.91%)
Mutual labels:  serialization
jsonapi-serializable
Conveniently build and efficiently render JSON API resources.
Stars: ✭ 43 (+95.45%)
Mutual labels:  serialization
surge
Simple, specialised, and efficient binary marshaling
Stars: ✭ 36 (+63.64%)
Mutual labels:  serialization
Unity-SerializeReferenceExtensions
Provide popup to specify the type of the field serialized by the [SerializeReference] attribute in the inspector.
Stars: ✭ 255 (+1059.09%)
Mutual labels:  serialization
Script
Script is an object-oriented interpreted programming language. Being migrated to CppUtils
Stars: ✭ 18 (-18.18%)
Mutual labels:  cpp20
photon mapping
minimal but extensible header only implementation of photon mapping in C++
Stars: ✭ 65 (+195.45%)
Mutual labels:  cpp20

json5

json5 is a small header only C++ library for parsing JSON or JSON5 data. It also comes with a simple reflection system for easy serialization and deserialization of C++ structs.

Quick Example:

#include <json5/json5_input.hpp>
#include <json5/json5_output.hpp>

struct Settings
{
	int x = 0;
	int y = 0;
	int width = 0;
	int height = 0;
	bool fullscreen = false;
	std::string renderer = "";

	JSON5_MEMBERS(x, y, width, height, fullscreen, renderer)
};

Settings s;

// Fill 's' instance from file
json5::from_file("settings.json", s);

// Save 's' to file
json5::to_file("settings.json", s);

json5.hpp

TBD

json5_input.hpp

Provides functions to load json5::document from string, stream or file.

json5_output.hpp

Provides functions to convert json5::document into string, stream or file.

json5_builder.hpp

json5_reflect.hpp

Basic supported types:

  • bool
  • int, float, double
  • std::string
  • std::vector, std::map, std::unordered_map, std::array
  • C array

json5_base.hpp

json5_filter.hpp

FAQ

TBD

Additional examples

Serialize custom type:

// Let's have a 3D vector struct:
struct vec3 { float x, y, z; };

// Let's have a triangle struct with 'vec3' members
struct Triangle
{
	vec3 a, b, c;
};

JSON5_CLASS(Triangle, a, b, c)

namespace json5::detail {

// Write vec3 as JSON array of 3 numbers
inline json5::value write( writer &w, const vec3 &in )
{
	w.push_array();
	w += write( w, in.x );
	w += write( w, in.y );
	w += write( w, in.z );
	return w.pop();
}

// Read vec3 from JSON array
inline error read( const json5::value &in, vec3 &out )
{
	return read( json5::array_view( in ), out.x, out.y, out.z );
}

} // namespace json5::detail

Serialize enum:

enum class MyEnum
{
	Zero,
	First,
	Second,
	Third
};

// (must be placed in global namespce, requires C++20)
JSON5_ENUM( MyEnum, Zero, First, Second, Third )
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].