Skip to content

Preprocessor definitions

You can customize how JasonPP behaves by defining preprocessor macros!

g++

g++ main.cpp JasonPP.cpp -D JASONPP_MY_MACRO=0.5 -D JASONPP_WARN_STFU

A complete list:

JASONPP_WARN_STFU

If defined, JasonPP will no longer print warnings

JASONPP_SPACES_PER_INDENT

Defines how many spaces will be used per indentation.
Default: 2

JASONPP_FLOAT_PRECISION

Defines the default maximum difference between two floating point values until JasonPP threats them as equal.
Also used for rendering. For example, set it to 0.01 and 3.14159265359 would be rendered as 3.14
Can be overridden for individual Json objects via SetFloatPrecision().
Default: 0.0000001

JASONPP_MAX_FLOAT_PRECISION

Defines the maximum float precision JasonPP will allow to be set (either by JASONPP_FLOAT_PRECISION or by SetFloatPrecision())
You generally do not want to change this.
Default: 0.0000000000000000000000000001

JASONPP_STRINGCONV_MINIFY

If defined, you will get minified json renders instead of pretty ones when converting a Json object to string
std::cout << myJson << std::endl;
or
std::string render = myJson;

JASONPP_RENDER_SORTED

If defined, JasonPP will render JsonBlocks ordered by their labels / keys, alphabetically, in ascending order.
I think this is kinda unnecessary, but it is apparently json convention.
I don't think any parser cares about order, i don't think its user friendly to just yeet the insertion order AND i know that it is more performant to not sort.

However, you have the option.

JASONPP_LEAVE_UTF8_ALONE

If defined, JasonPP will no longer parse / escape UTF-8 sequences like, for example, \u00b7.

JASONPP_NO_ADVANCED_FEATURESET

If defined, JasonPP will no longer remove comments, or convert hexadecimal / octal numbers.