JsonWax for Qt

NOW WITH SERIALIZATION

------ JsonWax JsonWax JsonWax --- JsonWax JsonWax JsonWax ------------ JsonWax JsonWax JsonWax ---- JsonWax JsonWax JsonWax ------------- JsonWax JsonWax JsonWax ---------- JsonWax JsonWax JsonWax ----------- JsonWax JsonWax JsonWax -------- JsonWax JsonWax JsonWax ------------ JsonWax JsonWax JsonWax ------- JsonWax JsonWax JsonWax JsonWax JsonWax JsonWax --------- JsonWax JsonWax JsonWax ----------- JsonWax JsonWax JsonWax -- JsonWax JsonWax JsonWax -------------- JsonWax JsonWax JsonWax ---------- JsonWax JsonWax JsonWax -------- JsonWax JsonWax JsonWax ---- JsonWax JsonWax JsonWax --------- JsonWax JsonWax JsonWax ---- JsonWax JsonWax JsonWax -- JsonWax JsonWax JsonWax ---------- JsonWax JsonWax JsonWax --------- JsonWax JsonWax JsonWax ------------- JsonWax JsonWax JsonWax - JsonWax JsonWax JsonWax ---------- JsonWax JsonWax JsonWax ----------- JsonWax JsonWax JsonWax ------------ JsonWax JsonWax JsonWax ---------- JsonWax JsonWax JsonWax -------------- JsonWax JsonWax JsonWax ------- JsonWax JsonWax JsonWax JsonWax JsonWax JsonWax -------- JsonWax JsonWax JsonWax ----- JsonWax JsonWax JsonWax JsonWax JsonWax JsonWax

WHAT IS IT?

JsonWax is a Qt C++ library for handling JSON-documents. It's an alternative to Qt's built-in set of JSON classes, made for Qt 5.7 or later.

The purpose is to shorten your JSON-handling code, and keep your mind on the structure of your document.

Essentially, finding a value in a JSON-document is like finding a file, where the path is a sequence of strings and/or numbers, which here is expressed as a QVariantList.

Instead of extracting objects from objects, you write the whole "directory" in one line, which makes nested JSON-documents easy to manage.

I have created easy-to-use functions for common operations such as: Setting/retrieving/deleting values, loading/saving the document to/from file, copying/moving data from one part of the document to another, and much more.

Furthermore, you can even serialize QObjects and other Qt data types to JSON. Both as readable strings (based on QTextStream), and as a Base64-encoded byte array (based on QDataStream).

Unfortunately this ease of use comes at the price of being slower than QJsonDocument.


JSON-document format JsonWax Github Repository


HOW DOES IT WORK?

When loading a JSON-document, JsonWax parses it, and converts it to an internal format, which allows for easy manipulation. All double, integer, bool and string values are converted to their actual types (a string is stored as a QString). Therefore, loading and saving a document will not always give the exact same data, because of the limitations of the types (double can only use so and so many digits; 10e2 will be converted to 1000, and such things). However, this means that you can easily store and retrieve basic values in/from a JSON-document.
When converting JsonWax's internal format back to a string, the JSON-Object will always have its keys sorted alphabetically, and JSON-Arrays will always keep the same order.

KNOWN BUGS

• (2018-02-25) JsonWax finds the working path in its constructor. That should instead be delayed until the first actual attempt at saving the file, as this current configuration will cause problems if QApplication hasn't been initialized.
• (2018-02-25) Fix compiling on Windows XP (since I started using thread_local this has been a problem).
• Currently, if you use special characters, and load a file using loadFile(), you'll need to make sure that the file is UTF-8 encoded. Fx. æ, ø, å can be stored in ANSI, but expecting them to be UTF-8 characters results in losing them. They would be shown as "�".
So make sure that the characters are preserved!

FUTURE GOALS FOR THIS PROJECT

• JSON schema validation.
• Remake the internal data structure, so that there will be better performance (back to the drawing board).