A universal serialization engine based on compile time reflection

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

Motivation

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

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

Tutorial

This Tutorial is provided to give you an view of how to iguana 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.

Defining meta data is very simple, just needs to difine a ‘REFLECTION’ micro.

Now let’s serialize person to json string.

This example will output:

serialize 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.

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

serialization of xml

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

a complicated example

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

At first define meta data:

Then call the simple interface:

Full sources:

  • https://github.com/qicosmos/iguana/blob/master/example.cpp

F.A.Q

  • Question: Why is the name called iguana?

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

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

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

    • Answer: Yes it is, because iguana is based on compile time reflection.
  • Question: I have found a bug, how do I notify?
    Answer: Create an issue at GitHub with a detailed description.

If you like iguana, please star it, thanks.

发表评论