Qx v0.5.7
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 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
 
concept  json_struct_inside
 
concept  json_struct_outside
 
concept  json_struct
 
concept  json_convertible
 
concept  json_override_convertible
 
concept  json_keyable
 
concept  json_collective
 
concept  json_associative
 
concept  json_containing
 
concept  json_optional
 

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.