AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::json::MappingOptions Struct Reference

JSON mapping options. More...

#include <mappingOptions.hpp>

Collaboration diagram for anch::json::MappingOptions:

Public Attributes

bool serialize_empty_col = true
bool serialize_null = false
uint16_t prettify_nbs = 0
bool serialize_check_constraints = false
bool deserialize_ignore_unknown_field = false
int64_t deserialize_max_discard_char = 0
std::size_t max_payload = 0
bool deserialize_check_constraints = true
std::size_t max_depth = 512
std::size_t buffer_size = 1024

Detailed Description

JSON mapping options.

Options are used to serialization options and deserialization behavior on unexcepted input stream

Author
Vincent Lachenal
Since
0.1

Member Data Documentation

◆ buffer_size

std::size_t anch::json::MappingOptions::buffer_size = 1024

Buffer size (used for deserialization for now)

◆ deserialize_check_constraints

bool anch::json::MappingOptions::deserialize_check_constraints = true

Check fields constraints ( required , minLength , minimum , ... given to ObjectMapper::registerField ) after reading values: anch::json::MappingError is raised with MISSING_FIELD or CONSTRAINT_VIOLATION error code. Default to true : usually enabled on server side to refuse invalid requests, disabled on client side where server responses are trusted.

Since
0.2

◆ deserialize_ignore_unknown_field

bool anch::json::MappingOptions::deserialize_ignore_unknown_field = false

Unknown will not raise error if true ; it can be usefull for client side implementation

◆ deserialize_max_discard_char

int64_t anch::json::MappingOptions::deserialize_max_discard_char = 0

Maximum discard characters before raising error. Use -1 value for unlimited discard characters. It can be usefull at development stage

◆ max_depth

std::size_t anch::json::MappingOptions::max_depth = 512

Maximum nesting depth of objects and arrays (root object or array is level 1 ) before raising error. It protects parser against stack overflow. Use 0 value for unlimited depth. Default to 512

◆ max_payload

std::size_t anch::json::MappingOptions::max_payload = 0

Maximum number of characters read from input stream before raising error ( anch::json::ErrorCode::PAYLOAD_TOO_LARGE ). Use 0 value for unlimited payload. The length of a string field is limited with its maxLength constraint.

◆ prettify_nbs

uint16_t anch::json::MappingOptions::prettify_nbs = 0

Serialization indentation number of spaces (0 means no prettifying). Default to 0

◆ serialize_check_constraints

bool anch::json::MappingOptions::serialize_check_constraints = false

Check fields constraints ( minLength , minimum , ... given to ObjectMapper::registerField ) before writing values: anch::json::MappingError is raised with CONSTRAINT_VIOLATION error code (the output stream contains the JSON written before the error). Default to false : usually enabled on client side to not send invalid requests, disabled on server side where responses are built by the server itself.
Required fields are always written ( null , [] or {} when empty, whatever serialize_null and serialize_empty_col options are).

Since
0.2

◆ serialize_empty_col

bool anch::json::MappingOptions::serialize_empty_col = true

Serialize empty collection as [] or {} for map . Default to true ; std::optional or pointer can be used

◆ serialize_null

bool anch::json::MappingOptions::serialize_null = false

Serialize null or empty string as null . Default to false


The documentation for this struct was generated from the following file: