All Projects → qicosmos → Iguana

qicosmos / Iguana

Licence: apache-2.0
universal serialization engine

Projects that are alternatives of or similar to Iguana

Fspickler
A fast multi-format message serializer for .NET
Stars: ✭ 299 (-37.84%)
Mutual labels:  json, xml, serialization, binary
Snodge
Randomly mutate JSON, XML, HTML forms, text and binary data for fuzz testing
Stars: ✭ 121 (-74.84%)
Mutual labels:  json, xml, binary
Fhir.js
Node.JS library for serializing/deserializing FHIR resources between JS/JSON and XML using various node.js XML libraries
Stars: ✭ 61 (-87.32%)
Mutual labels:  json, xml, serialization
Borer
Efficient CBOR and JSON (de)serialization in Scala
Stars: ✭ 131 (-72.77%)
Mutual labels:  json, serialization, binary
Autocser
AutoCSer is a high-performance RPC framework. AutoCSer 是一个以高效率为目标向导的整体开发框架。主要包括 TCP 接口服务框架、TCP 函数服务框架、远程表达式链组件、前后端一体 WEB 视图框架、ORM 内存索引缓存框架、日志流内存数据库缓存组件、消息队列组件、二进制 / JSON / XML 数据序列化 等一系列无缝集成的高性能组件。
Stars: ✭ 140 (-70.89%)
Mutual labels:  json, xml, serialization
Render
Go package for easily rendering JSON, XML, binary data, and HTML templates responses.
Stars: ✭ 1,562 (+224.74%)
Mutual labels:  json, xml, binary
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (-63.41%)
Mutual labels:  json, xml, serialization
Chronicle Wire
A Java Serialisation Library that supports multiple formats
Stars: ✭ 204 (-57.59%)
Mutual labels:  json, serialization, binary
Tbox
🎁 A glib-like multi-platform c library
Stars: ✭ 3,800 (+690.02%)
Mutual labels:  json, xml
Node Rest Client
REST API client from node.js
Stars: ✭ 365 (-24.12%)
Mutual labels:  json, xml
Ceras
Universal binary serializer for a wide variety of scenarios https://discord.gg/FGaCX4c
Stars: ✭ 374 (-22.25%)
Mutual labels:  serialization, binary
Hashover Next
This branch will be HashOver 2.0
Stars: ✭ 353 (-26.61%)
Mutual labels:  json, xml
Cppwebframework
​The C++ Web Framework (CWF) is a MVC web framework, Open Source, under MIT License, using C++ with Qt to be used in the development of web applications.
Stars: ✭ 348 (-27.65%)
Mutual labels:  json, xml
Leopotamgrouplibraryunity
Tools library for unity 3d game engine: animator graph helpers, serialization (json), localization, event routing (eventbus, ui actions), embedded scripting, uGui xml markup, threading, tweening, in-memory protection and other helpers (pure C#)
Stars: ✭ 373 (-22.45%)
Mutual labels:  json, serialization
Velocypack
A fast and compact format for serialization and storage
Stars: ✭ 347 (-27.86%)
Mutual labels:  json, serialization
Handyjson
A handy swift json-object serialization/deserialization library
Stars: ✭ 3,913 (+713.51%)
Mutual labels:  json, serialization
Stream Parser
⚡ PHP7 / Laravel Multi-format Streaming Parser
Stars: ✭ 391 (-18.71%)
Mutual labels:  json, xml
Xidel
Command line tool to download and extract data from HTML/XML pages or JSON-APIs, using CSS, XPath 3.0, XQuery 3.0, JSONiq or pattern matching. It can also create new or transformed XML/HTML/JSON documents.
Stars: ✭ 335 (-30.35%)
Mutual labels:  json, xml
Choetl
ETL Framework for .NET / c# (Parser / Writer for CSV, Flat, Xml, JSON, Key-Value, Parquet, Yaml, Avro formatted files)
Stars: ✭ 372 (-22.66%)
Mutual labels:  json, xml
Wiremock
A tool for mocking HTTP services
Stars: ✭ 4,790 (+895.84%)
Mutual labels:  json, xml

A Universal Serialization Engine Based on compile-time Reflection

iguana is a modern, universal and easy-to-use serialization engine developed in c++17.

Motivation

Serialize an object to any other format data with compile-time reflection, such as json, xml, binary, table and so on. This library is designed to unify and simplify serialization in a portable cross-platform manner. This library is also easy to extend, and you can serialize any format of data with the library. This library provides a portable cross-platform way of:

  • serialization of json
  • serialization of xml
  • serialization of any customized format

Tutorial

This Tutorial is provided to give you a view of how iguana works for serialization.

Serialization of json

The first thing to do when you serialize an object is to define meta data. There is an example of defining meta data.

struct person
{
	std::string  name;
	int          age;
};

REFLECTION(person, name, age) //define meta data

Defining meta data is very simple, and just needs to define in a REFLECTION macro.

Now let's serialize person to json string.

person p = { "tom", 28 };

iguana::string_stream ss;
iguana::json::to_json(ss, p);

std::cout << ss.str() << std::endl; 

This example will output:

{"name":"tom","age":28}

Serializing person to json string is also very simple, just need to call to_json method, there is nothing more.

How about deserialization of json? Look at the follow example.

const char * json = "{ \"name\" : \"tom\", \"age\" : 28}";

person p;
iguana::json::from_json(p, json);

It's as simple as serialization, just need to call from_json method.

Serialization of xml

Serialization of xml is similar to json. The first step is also defining meta data as above. This is a complete example.

person p = {"admin", 20};

iguana::string_stream ss;
iguana::xml::to_xml(ss, p);

std::cout << ss.str() << std::endl;

std::string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\">  <name>buke</name> <id>1</id>";
iguana::xml::from_xml(p, xml.data(), xml.length());

A complicated example

iguana can deal with objects which contain another objects and containers. Here is the example:

At first, we define the meta data:

struct one_t
{
	int id;
};
REFLECTION(one_t, id);

struct two
{
	std::string name;
	one_t one;
	int age;
};
REFLECTION(two, name, one, age);

struct composit_t
{
	int a;
	std::vector<std::string> b;
	int c;
	std::map<int, int> d;
	std::unordered_map<int, int> e;
	double f;
	std::list<one_t> g;
};
REFLECTION(composit_t, a, b, c, d, e, f, g);

Then call the simple interface:

one_t one = { 2 };
composit_t composit = { 1,{ "tom", "jack" }, 3,{ { 2,3 } },{ { 5,6 } }, 5.3,{ one } };
iguana::string_stream ss;
iguana::json::to_json(ss, composit);
std::cout << ss.str() << std::endl;

const char* str_comp = R"({"a":1, "b":["tom", "jack"], "c":3, "d":{"2":3,"5":6},"e":{"3":4},"f":5.3,"g":[{"id":1},{"id":2}])";
composit_t comp;
iguana::json::from_json(comp, str_comp);

How to solve the problem of unicode path in a json file?

If there is an unicode string as a path in a json file, however iguana parse the file as utf-8, so maybe you can see some strange characters after parse.

It's ok, because you see the utf-8 strings. The problem is you can't use the string directly, such as use std::ifstream to open the file with the unicode string path.

We can slove the problem1 easily with c++17:

	//the p.path is a unicode string path
	std::ifstream in(std::filesystem::u8path(p.path)); //std::filesystem::u8path help us
	//now you can operate the file

Full sources:

F.A.Q

  • Question: Why is the library called iguana?

    • Answer: I think serialization is like an iguana, because the only difference is the displaying format, however the meta data is never changed. With changeless meta data and reflection, you can serialize an object to any format, which is like how an iguana does.
  • Question: Does iguana support raw pointer?

    • Answer: No. iguana doesn't support raw pointer, but it will support smart pointer in the future.
  • Question: Is iguana thread-safe?

    • Answer: Not yet, but it's not a problem, you can use lock before calling from_json or to_json.
  • Question: Is iguana high performance?

    • Answer: Yes, it is, because iguana is based on compile-time reflection.
  • Question: I found a bug, how could I report?

    • Answer: Create an issue on GitHub with a detailed description.

Update

  1. Support C++17
  2. Support disorderly parse json, a new interface from_json0 do this, however it is slower than from_json.
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].