QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
Static Public Member Functions | List of all members
QgsJSONUtils Class Reference

Helper utilities for working with JSON and GeoJSON conversions. More...

#include <qgsjsonutils.h>

Static Public Member Functions

static QString encodeValue (const QVariant &value)
 Encodes a value to a JSON string representation, adding appropriate quotations and escaping where required. More...
 
static QString exportAttributes (const QgsFeature &feature)
 Exports all attributes from a QgsFeature as a JSON map type. More...
 
static QgsFeatureList stringToFeatureList (const QString &string, const QgsFields &fields, QTextCodec *encoding)
 Attempts to parse a GeoJSON string to a collection of features. More...
 
static QgsFields stringToFields (const QString &string, QTextCodec *encoding)
 Attempts to retrieve the fields from a GeoJSON string representing a collection of features. More...
 

Detailed Description

Helper utilities for working with JSON and GeoJSON conversions.

Note
Added in version 2.16

Definition at line 207 of file qgsjsonutils.h.

Member Function Documentation

QString QgsJSONUtils::encodeValue ( const QVariant value)
static

Encodes a value to a JSON string representation, adding appropriate quotations and escaping where required.

Parameters
valuevalue to encode
Returns
encoded value

Definition at line 236 of file qgsjsonutils.cpp.

QString QgsJSONUtils::exportAttributes ( const QgsFeature feature)
static

Exports all attributes from a QgsFeature as a JSON map type.

Parameters
featurefeature to export

Definition at line 302 of file qgsjsonutils.cpp.

QgsFeatureList QgsJSONUtils::stringToFeatureList ( const QString string,
const QgsFields fields,
QTextCodec encoding 
)
static

Attempts to parse a GeoJSON string to a collection of features.

Parameters
stringGeoJSON string to parse
fieldsfields collection to use for parsed features
encodingtext encoding
Returns
list of parsed features, or an empty list if no features could be parsed
See also
stringToFields()
Note
this function is a wrapper around QgsOgrUtils::stringToFeatureList()

Definition at line 226 of file qgsjsonutils.cpp.

QgsFields QgsJSONUtils::stringToFields ( const QString string,
QTextCodec encoding 
)
static

Attempts to retrieve the fields from a GeoJSON string representing a collection of features.

Parameters
stringGeoJSON string to parse
encodingtext encoding
Returns
retrieved fields collection, or an empty list if no fields could be determined from the string
See also
stringToFeatureList()
Note
this function is a wrapper around QgsOgrUtils::stringToFields()

Definition at line 231 of file qgsjsonutils.cpp.


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