29#include <nlohmann/json_fwd.hpp>
30using namespace nlohmann;
230 QString exportFeature(
231 const QgsFeature &feature,
const QVariantMap &extraProperties = QVariantMap(),
const QVariant &
id = QVariant(),
int indent = -1,
const QVariantMap &extraMembers = QVariantMap()
244 json exportFeatureToJsonObject(
const QgsFeature &feature,
const QVariantMap &extraProperties = QVariantMap(),
const QVariant &
id = QVariant(),
const QVariantMap &extraMembers = QVariantMap() ) const
254 QString exportFeatures( const
QgsFeatureList &features,
int indent = -1 ) const;
280 Qgis::GeoJsonProfile geoJsonProfile() const;
286 void setGeoJsonProfile(
Qgis::GeoJsonProfile profile );
302 bool mIncludeGeometry = true;
305 bool mIncludeAttributes = true;
308 bool mIncludeRelatedAttributes = false;
317 bool mAttributeDisplayName = false;
319 bool mTransformGeometries = true;
323 bool mUseFieldFormatters = true;
326 mutable
bool mOmitCollectionLevelInformation = false;
328 Qgis::GeoJsonProfile mGeoJsonProfile =
Qgis::GeoJsonProfile::Legacy;
367 Q_INVOKABLE
static QString
encodeValue(
const QVariant &value );
400 Q_INVOKABLE
static QVariantList
parseArray(
const QString &json, QMetaType::Type type = QMetaType::Type::UnknownType );
410 Q_INVOKABLE Q_DECL_DEPRECATED
static QVariantList
parseArray(
const QString &json, QVariant::Type type )
SIP_DEPRECATED;
461 static QVariant
parseJson(
const std::string &jsonString, QString &error )
SIP_SKIP;
Provides global constants and enumerations for use throughout the application.
GeoJsonProfile
GeoJson export Profile according to OGC Features and Geometries JSON - Part 1: Core https://docs....
@ Legacy
Legacy GeoJson profile used in QGIS prior to 4.2, which included some non-standard extensions and dev...
Represents a coordinate reference system (CRS).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
void setIncludeGeometry(bool includeGeometry)
Sets whether to include geometry in the JSON exports.
void setIncludeRelated(bool includeRelated)
Sets whether to include attributes of features linked via references in the JSON exports.
void setPrecision(int precision)
Sets the maximum number of decimal places to use in geometry coordinates.
void setAttributes(const QgsAttributeList &attributes)
Sets the list of attributes to include in the JSON exports.
bool attributeDisplayName() const
Returns whether original names of attributes or aliases are printed.
QgsAttributeList excludedAttributes() const
Returns a list of attributes which will be specifically excluded from the JSON exports.
void setUseFieldFormatters(bool useFieldFormatters)
Sets whether field formatters (of type KeyValue, List, ValueRelation, ValueMap) are used to export ra...
void setIncludeAttributes(bool includeAttributes)
Sets whether to include attributes in the JSON exports.
bool useFieldFormatters() const
Returned whether field formatters (of type KeyValue, List, ValueRelation, ValueMap) are used to expor...
QgsVectorLayer * vectorLayer() const
Returns the associated vector layer, if set.
void setTransformGeometries(bool activate)
Sets whether geometries should be transformed in CRS84 (default behavior) or just keep as it is.
void setAttributeDisplayName(bool displayName)
Sets whether to print original names of attributes or aliases if defined.
QgsAttributeList attributes() const
Returns the list of attributes which will be included in the JSON exports, or an empty list if all at...
void setExcludedAttributes(const QgsAttributeList &attributes)
Sets a list of attributes to specifically exclude from the JSON exports.
bool includeAttributes() const
Returns whether attributes will be included in the JSON exports.
int precision() const
Returns the maximum number of decimal places to use in geometry coordinates.
bool includeRelated() const
Returns whether attributes of related (child) features will be included in the JSON exports.
QgsJsonExporter(QgsVectorLayer *vectorLayer=nullptr, int precision=6)
Constructor for QgsJsonExporter.
bool includeGeometry() const
Returns whether geometry will be included in the JSON exports.
Helper utilities for working with JSON and GeoJSON conversions.
static void addCrsInfo(json &value, const QgsCoordinateReferenceSystem &crs, Qgis::GeoJsonProfile profile=Qgis::GeoJsonProfile::Legacy)
Add crs information entry in json object regarding old GeoJSON specification format if it differs fro...
static QgsGeometry geometryFromGeoJson(const json &geometry)
Parses a GeoJSON "geometry" value to a QgsGeometry object.
static QString exportAttributes(const QgsFeature &feature, QgsVectorLayer *layer=nullptr, const QVector< QVariant > &attributeWidgetCaches=QVector< QVariant >())
Exports all attributes from a QgsFeature as a JSON map type.
static QgsFeatureList stringToFeatureList(const QString &string, const QgsFields &fields=QgsFields(), QTextCodec *encoding SIP_PYARGREMOVE6=nullptr)
Attempts to parse a GeoJSON string to a collection of features.
static Q_INVOKABLE QString encodeValue(const QVariant &value)
Encodes a value to a JSON string representation, adding appropriate quotations and escaping where req...
static QVariant parseJson(const std::string &jsonString)
Converts JSON jsonString to a QVariant, in case of parsing error an invalid QVariant is returned and ...
static QVariant geometryToGeoJsonVariant(const QgsGeometry &geometry)
Converts a geometry to a GeoJSON compatible variant.
static Q_INVOKABLE QVariantList parseArray(const QString &json, QMetaType::Type type=QMetaType::Type::UnknownType)
Parse a simple array (depth=1).
static json exportAttributesToJsonObject(const QgsFeature &feature, QgsVectorLayer *layer=nullptr, const QVector< QVariant > &attributeWidgetCaches=QVector< QVariant >(), bool useFieldFormatters=true)
Exports all attributes from a QgsFeature as a json object.
static QVariant jsonToVariant(const json &value)
Converts a JSON value to a QVariant, in case of parsing error an invalid QVariant is returned.
static QgsFields stringToFields(const QString &string, QTextCodec *encoding SIP_PYARGREMOVE6=nullptr)
Attempts to retrieve the fields from a GeoJSON string representing a collection of features.
static json jsonFromVariant(const QVariant &v)
Converts a QVariant v to a json object.
Represents a vector layer which manages a vector based dataset.
QList< QgsFeature > QgsFeatureList
QList< int > QgsAttributeList