Cute Chess 0.1
JsonSerializer Class Reference

A JSON (JavaScript Object Notation) serializer. More...

#include <jsonserializer.h>

Public Member Functions

QString errorString () const
bool hasError () const
 JsonSerializer (const QVariant &data)
bool serialize (QTextStream &stream)

Detailed Description

A JSON (JavaScript Object Notation) serializer.

JsonSerializer converts QVariants into JSON data and writes it to a text stream. The following QVariant types are supported:

  • QVariant::Invalid (JSON null)
  • QVariant::Bool (JSON boolean)
  • QVariant::ByteArray (JSON string)
  • QVariant::List (JSON array)
  • QVariant::Map (JSON object)
  • QVariant::String (JSON string)
  • QVariant::StringList (JSON array)
  • any other type that can be converted into a string by QVariant

JSON specification: http://json.org/

See also
JsonParser

Constructor & Destructor Documentation

◆ JsonSerializer()

JsonSerializer::JsonSerializer ( const QVariant & data)

Creates a new serializer that operates on data.

Member Function Documentation

◆ errorString()

QString JsonSerializer::errorString ( ) const

Returns a detailed description of the error.

◆ hasError()

bool JsonSerializer::hasError ( ) const

Returns true if an error occured.

◆ serialize()

bool JsonSerializer::serialize ( QTextStream & stream)

Converts the data into JSON format and writes it to stream.

Returns false if an invalid or unsupported variant type is encountered. Otherwise returns true.


The documentation for this class was generated from the following files: