All Projects → smurfomen → QSerializer

smurfomen / QSerializer

Licence: MIT License
This repo for Qt/C++ serialization objects in JSON or XML based on QtCore

Programming Languages

C++
36643 projects - #6 most used programming language
QMake
1090 projects

Projects that are alternatives of or similar to QSerializer

Fhir.js
Node.JS library for serializing/deserializing FHIR resources between JS/JSON and XML using various node.js XML libraries
Stars: ✭ 61 (+84.85%)
Mutual labels:  serialization, xml
Quick Xml
Rust high performance xml reader and writer
Stars: ✭ 480 (+1354.55%)
Mutual labels:  serialization, xml
Fspickler
A fast multi-format message serializer for .NET
Stars: ✭ 299 (+806.06%)
Mutual labels:  serialization, xml
Home
A configurable and eXtensible Xml serializer for .NET.
Stars: ✭ 208 (+530.3%)
Mutual labels:  serialization, xml
Xmlutil
XML Serialization library for Kotlin
Stars: ✭ 143 (+333.33%)
Mutual labels:  serialization, xml
Protobuf Java Format
Provide serialization and de-serialization of different formats based on Google’s protobuf Message. Enables overriding the default (byte array) output to text based formats such as XML, JSON and HTML.
Stars: ✭ 134 (+306.06%)
Mutual labels:  serialization, xml
Iguana
universal serialization engine
Stars: ✭ 481 (+1357.58%)
Mutual labels:  serialization, xml
Autocser
AutoCSer is a high-performance RPC framework. AutoCSer 是一个以高效率为目标向导的整体开发框架。主要包括 TCP 接口服务框架、TCP 函数服务框架、远程表达式链组件、前后端一体 WEB 视图框架、ORM 内存索引缓存框架、日志流内存数据库缓存组件、消息队列组件、二进制 / JSON / XML 数据序列化 等一系列无缝集成的高性能组件。
Stars: ✭ 140 (+324.24%)
Mutual labels:  serialization, xml
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (+433.33%)
Mutual labels:  serialization, xml
MetaCPP
C++ Reflection & Serialization using Clang's LibTooling
Stars: ✭ 44 (+33.33%)
Mutual labels:  serialization, meta
xgen
XSD (XML Schema Definition) parser and Go/C/Java/Rust/TypeScript code generator
Stars: ✭ 153 (+363.64%)
Mutual labels:  xml
utils.js
👷 🔧 zero dependencies vanilla JavaScript utils.
Stars: ✭ 14 (-57.58%)
Mutual labels:  xml
tinypacks
A data serialization format for constrained environments like 8-bit and 16-bit microcontrollers.
Stars: ✭ 30 (-9.09%)
Mutual labels:  serialization
fox
A Fortran XML library
Stars: ✭ 51 (+54.55%)
Mutual labels:  xml
ruby-marshal
Haskell library to parse a subset of Ruby objects serialised with Marshal.dump
Stars: ✭ 30 (-9.09%)
Mutual labels:  serialization
javascript-serialization-benchmark
Comparison and benchmark of JavaScript serialization libraries (Protocol Buffer, Avro, BSON, etc.)
Stars: ✭ 54 (+63.64%)
Mutual labels:  serialization
xrechnung-visualization
XSL transformators for web and pdf rendering of German CIUS XRechnung or EN16931-1:2017 [MIRROR OF GitLab]
Stars: ✭ 26 (-21.21%)
Mutual labels:  xml
statham-schema
Statham is a Python Model Parsing Library for JSON Schema.
Stars: ✭ 21 (-36.36%)
Mutual labels:  serialization
crystalizer
(De)serialize any Crystal object - out of the box. Supports JSON, YAML and Byte format.
Stars: ✭ 32 (-3.03%)
Mutual labels:  serialization
json2xml
json to xml converter in python3
Stars: ✭ 76 (+130.3%)
Mutual labels:  xml

logo This project is designed to convert data from an object view to JSON or XML and opposite in the Qt/C++ ecosystem. C ++ classes by default do not have the required meta-object information for serializing class fields, but Qt is equipped with its own highly efficient meta-object system. An important feature of the QSerializer is the ability to specify serializable fields of the class without having to serialize the entire class. QSerilaizer generate code and declare Q_PROPERTY for every declared member of class. This is convenient because you do not need to create separate structures or classes for serialization of write some code to serialize every class, it's just included to QSerializer.

Installation

Download repository

$ git clone https://github.com/smurfomen/QSerializer.git

Just include qserializer.h in your project and enjoy simple serialization. qserializer.h located in src folder. Set compiler define QS_HAS_JSON or QS_HAS_XML for enabling support for xml or json. Enable both at the same time is not supported.


A demo project for using QSerializer located in example folder.

Workflow

To get started, include qserializer.h in your code.

Create serialization class

For create serializable member of class and generate propertyes, use macro:

  • QS_FIELD
  • QS_COLLECTION
  • QS_OBJECT
  • QS_COLLECTION_OBJECTS
  • QS_QT_DICT
  • QS_QT_DICT_OBJECTS
  • QS_STL_DICT
  • QS_STL_DICT_OBJECTS

If you want only declare exists fields - use macro QS_JSON_FIELD, QS_XML_FIELD, QS_JSON_COLLECTION and other (look at qserializer.h)

Inherit from QSerializer

Inherit from QSerializer, use macro QS_SERIALIZABLE or override metaObject method and declare some serializable fields.
In this case you must use Q_GADGET in your class.

class User : public QSerializer
{
Q_GADGET
QS_SERIALIZABLE
// Create data members to be serialized - you can use this members in code
QS_FIELD(int, age)
QS_COLLECTION(QVector, QString, parents)
};

Serialize

Now you can serialize object of this class to JSON or XML. For example:

User u;
u.age = 20;
u.parents.append("Mary");
u.parents.append("Jeff");

/* case: json value */
QJsonObject jsonUser = u.toJson();

/* case: raw json data */
QByteArray djson = u.toRawJson();

/* case: xml-dom */
QDomNode xmlUser = u.toXml();

/* case: raw xml data */
QByteArray dxml = u.toRawXml();

Deserialize

Opposite of the serialization procedure is the deserialization procedure. You can deserialize object from JSON or XML, declared fields will be modified or resets to default for this type values. For example:

...
User u;

/* case: json value */
QJsonObject json;
u.fromJson(json);

/* case: raw json data */
QByteArray rawJson;
u.fromJson(rawJson);

/* case: xml-dom */
QDomNode xml;
u.fromXml(xml);

/* case: raw xml data */
QByteArray rawXml;
u.fromXml(rawXml);

Macro description

Macro Description
QSERIALIZABLE Make class or struct is serializable to QSerializer (override QMetaObject method and define Q_GADGET macro)
QS_FIELD Create serializable simple field
QS_COLLECTION Create serializable collection values of primitive types
QS_OBJECT Create serializable inner custom type object
QS_COLLECTION_OBJECTS Create serializable collection of custom type objects
QS_QT_DICT Create serializable dictionary of primitive type values FOR QT DICTIONARY TYPES
QS_QT_DICT_OBJECTS Create serializable dictionary of custom type values FOR QT DICTIONARY TYPES
QS_STL_DICT Create serializable dictionary of primitive type values FOR STL DICTIONARY TYPES
QS_STL_DICT_OBJECTS Create serializable dictionary of custom type values FOR STL DICTIONARY TYPES
QS_SERIALIZABLE Override method metaObject and make class serializable
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].