Create more granular macros for specific non-strict features
Enable strict mode and parent links by default
Details
More granular macros
This PR builds on the changes from PR #194. With PR #194, there are three specific ways in which non-strict mode diverges from RFC 8259:
Primitives may contain any character except whitespace and those with special meaning in JSON ({}[],:").
Strings may contain control characters (\x01 - \x1F) and invalid escape sequences
Primitives may be used as object keys
Some projects using jsmn might want some of these features, but not all. For example, a project might want to enable (1) to improve performance or shrink code size, but leave (3) disabled to help catch bugs.
For this purpose, this PR creates three new macros: JSMN_PERMISSIVE_PRIMITIVES for (1), JSMN_PERMISSIVE_STRINGS for (2), and JSMN_PRIMITIVE_KEYS for (3). These can be defined individually, or defining JSMN_NON_STRICT will cause all to be defined.
Enable strict mode and parent links by default
With this PR, strict RFC 8259 compliance and parent links become the default behavior. New macros JSMN_LOW_MEMORY and JSMN_NON_STRICT disable these behaviors.
JSMN_PARENT_LINKS still exists, but is defined by default unless JSMN_LOW_MEMORY is defined.
JSMN_NON_STRICT replaces JSMN_STRICT. When defined, all non-strict features are enabled.
This PR does two things:
Details
More granular macros
This PR builds on the changes from PR #194. With PR #194, there are three specific ways in which non-strict mode diverges from RFC 8259:
{}[],:"
).\x01
-\x1F
) and invalid escape sequencesSome projects using jsmn might want some of these features, but not all. For example, a project might want to enable (1) to improve performance or shrink code size, but leave (3) disabled to help catch bugs.
For this purpose, this PR creates three new macros:
JSMN_PERMISSIVE_PRIMITIVES
for (1),JSMN_PERMISSIVE_STRINGS
for (2), andJSMN_PRIMITIVE_KEYS
for (3). These can be defined individually, or definingJSMN_NON_STRICT
will cause all to be defined.Enable strict mode and parent links by default
With this PR, strict RFC 8259 compliance and parent links become the default behavior. New macros
JSMN_LOW_MEMORY
andJSMN_NON_STRICT
disable these behaviors.JSMN_PARENT_LINKS
still exists, but is defined by default unlessJSMN_LOW_MEMORY
is defined.JSMN_NON_STRICT
replacesJSMN_STRICT
. When defined, all non-strict features are enabled.