Qx v0.5.8
Qt Extensions Library
Loading...
Searching...
No Matches
QxJson Namespace Reference

The QxJson namespace encapsulates the user-extensible implementation of Qx's JSON parsing facilities.

Classes

class  Array
 The array class represents a JSON array node for use in error contexts. More...
 
class  ArrayElement
 The array element key class represents a JSON Array element node for use in error contexts. More...
 
struct  Converter
 The Converter template struct acts as an interface that carries details on how to parse/serialize JSON to various types. More...
 
class  Document
 The document class represents a JSON document node for use in error contexts. More...
 
class  File
 The file class represents a JSON file node for use in error contexts. More...
 
struct  MemberOverrideCoverter
 
class  Object
 The object class represents a JSON object node for use in error contexts. More...
 
class  ObjectKey
 The object key class represents a JSON Object key node for use in error contexts. More...
 
struct  QxJsonMetaStructOutside
 

Concepts

concept  qjson_type
 Specifies that a type is one of the fundamental JSON types within Qt's JSON system.
 
concept  json_struct_inside
 Specifies that a type is a JSON-tied struct registered with QX_JSON_STRUCT().
 
concept  json_struct_outside
 Specifies that a type is a JSON-tied struct registered with QX_JSON_STRUCT_OUTSIDE().
 
concept  json_struct
 Specifies that a type is a JSON-tied struct.
 
concept  json_convertible
 Specifies that a type is generally convertible to/from JSON.
 
concept  json_override_convertible
 
concept  json_keyable
 Specifies that a type has a known method for creating a corresponding key.
 
concept  json_collective
 Specifies that a type is a non-associative container, the value type of which is convertible to/from JSON.
 
concept  json_associative
 Specifies that a type is an associative container, the value type of which is convertible, to/from JSON, and for which a key/value type specializaton of keygen() exists.
 
concept  json_containing
 Specifies that a type is a container, and abides by the other corresponding restrictions for that kind of a container.
 
concept  json_optional
 Specifies that a type is a specialization of std::optional that manages values of a JSON convertible type.
 

Typedefs

using ContextNode = std::variant<File, Document, Object, ObjectKey, Array, ArrayElement>
 

Functions

template<typename Key , class Value >
Key keygen (const Value &value)=delete
 The keygen template function acts as an interface through which the derivation of a key for a given type, when used in associative containers, is defined.
 

Typedef Documentation

◆ ContextNode

Any JSON context node type.

Function Documentation

◆ keygen()

template<typename Key , class Value >
template< typename Key, class Value > Key QxJson::keygen ( const Value & value)
delete

Any otherwise convertible JSON type can be parsed into a map as long as a specialization of keygen() exists for that type.

Support for additional types can be added like so:

struct MyStruct
{
int number;
QString name;
QX_JSON_STRUCT(number, name);
};
namespace QxJson
{
template<>
QString keygen<QString, MyStruct>(const MyStruct& value)
{
// This specialization enables the use of QHash<QString, MyStruct>
// or QMap<QString, MyStruct> to represent a JSON array of JSON objects
// that are tied to MyStruct. The 'name' member is used as the key for each value.
return value.name;
};
}
// Use in another struct
struct OtherStruct
{
bool enabled;
QX_JSON_STRUCT(enabled, myStructs);
};
See also
qx-json.h and Converter.