From 750f63fb6f5e05bc208605ec77eb1bd0f5bf651b Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 23 Aug 2018 14:46:41 +0200 Subject: [PATCH 01/10] Adjust representation of arrays and maps in expressions array representation: ``` array: [ 1, 2, 3 ] ``` before: ``` array: 1, 2, 3 ``` map representation: ``` map: { one: 1, two: 2, three: 3 } ``` before ``` map: one: 1, two: 2, three: 3 ``` --- src/core/expression/qgsexpression.cpp | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/core/expression/qgsexpression.cpp b/src/core/expression/qgsexpression.cpp index c6e6575fab6..aecaa7c2fc8 100644 --- a/src/core/expression/qgsexpression.cpp +++ b/src/core/expression/qgsexpression.cpp @@ -903,34 +903,44 @@ QString QgsExpression::formatPreviewString( const QVariant &value ) } else if ( value.type() == QVariant::Map ) { - QString mapStr; + QString mapStr = QStringLiteral( "{ " ); const QVariantMap map = value.toMap(); + QString separator; for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it ) { - if ( !mapStr.isEmpty() ) mapStr.append( ", " ); + mapStr.append( separator ); + if ( separator.isEmpty() ) + separator = QStringLiteral( ", " ); + mapStr.append( it.key() ).append( ": " ).append( formatPreviewString( it.value() ) ); - if ( mapStr.length() > MAX_PREVIEW + 3 ) + if ( mapStr.length() > MAX_PREVIEW + 5 ) { - mapStr = QString( tr( "%1…" ) ).arg( mapStr.left( MAX_PREVIEW ) ); + mapStr = tr( "%1…" ).arg( mapStr.left( MAX_PREVIEW ) ); break; } } + mapStr += QStringLiteral( " }" ); return tr( "<map: %1>" ).arg( mapStr ); } else if ( value.type() == QVariant::List || value.type() == QVariant::StringList ) { - QString listStr; + QString listStr = QStringLiteral( "[ " ); const QVariantList list = value.toList(); - for ( QVariantList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it ) + QString separator; + for ( const QVariant &arrayValue : list ) { - if ( !listStr.isEmpty() ) listStr.append( ", " ); - listStr.append( formatPreviewString( *it ) ); - if ( listStr.length() > MAX_PREVIEW + 3 ) + listStr.append( separator ); + if ( separator.isEmpty() ) + separator = QStringLiteral( ", " ); + + listStr.append( formatPreviewString( arrayValue ) ); + if ( listStr.length() > MAX_PREVIEW + 5 ) { listStr = QString( tr( "%1…" ) ).arg( listStr.left( MAX_PREVIEW ) ); break; } } + listStr += QStringLiteral( " ]" ); return tr( "<array: %1>" ).arg( listStr ); } else From 4fecc2e90aa33c74dd509503e11b3c62e75632dc Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 23 Aug 2018 14:48:26 +0200 Subject: [PATCH 02/10] Code cleanup --- src/gui/qgsexpressionbuilderwidget.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/qgsexpressionbuilderwidget.cpp b/src/gui/qgsexpressionbuilderwidget.cpp index 2f918e6ad74..a2d5601bd4e 100644 --- a/src/gui/qgsexpressionbuilderwidget.cpp +++ b/src/gui/qgsexpressionbuilderwidget.cpp @@ -279,7 +279,7 @@ void QgsExpressionBuilderWidget::btnNewFile_pressed() bool ok; QString text = QInputDialog::getText( this, tr( "Enter new file name" ), tr( "File name:" ), QLineEdit::Normal, - QLatin1String( "" ), &ok ); + QString(), &ok ); if ( ok && !text.isEmpty() ) { newFunctionFile( text ); @@ -348,7 +348,7 @@ void QgsExpressionBuilderWidget::loadFieldNames( const QgsFields &fields ) { QString fieldName = fields.at( i ).name(); fieldNames << fieldName; - registerItem( QStringLiteral( "Fields and Values" ), fieldName, " \"" + fieldName + "\" ", QLatin1String( "" ), QgsExpressionItem::Field, false, i ); + registerItem( QStringLiteral( "Fields and Values" ), fieldName, " \"" + fieldName + "\" ", QString(), QgsExpressionItem::Field, false, i ); } // highlighter->addFields( fieldNames ); } @@ -426,7 +426,7 @@ void QgsExpressionBuilderWidget::registerItem( const QString &group, else { // If the group doesn't exist yet we make it first. - QgsExpressionItem *newgroupNode = new QgsExpressionItem( QgsExpression::group( group ), QLatin1String( "" ), QgsExpressionItem::Header ); + QgsExpressionItem *newgroupNode = new QgsExpressionItem( QgsExpression::group( group ), QString(), QgsExpressionItem::Header ); newgroupNode->setData( group, Qt::UserRole ); //Recent group should always be last group newgroupNode->setData( group.startsWith( QLatin1String( "Recent (" ) ) ? 2 : 1, QgsExpressionItem::CUSTOM_SORT_ROLE ); @@ -628,9 +628,9 @@ void QgsExpressionBuilderWidget::txtExpressionString_textChanged() if ( text.isEmpty() ) { lblPreview->clear(); - lblPreview->setStyleSheet( QLatin1String( "" ) ); - txtExpressionString->setToolTip( QLatin1String( "" ) ); - lblPreview->setToolTip( QLatin1String( "" ) ); + lblPreview->setStyleSheet( QString() ); + txtExpressionString->setToolTip( QString() ); + lblPreview->setToolTip( QString() ); emit expressionParsed( false ); setParserError( true ); setEvalError( true ); @@ -1064,7 +1064,7 @@ QString QgsExpressionBuilderWidget::helpStylesheet() const QString QgsExpressionBuilderWidget::loadFunctionHelp( QgsExpressionItem *expressionItem ) { if ( !expressionItem ) - return QLatin1String( "" ); + return QString(); QString helpContents = expressionItem->getHelpText(); From 40d0dfa315048e80bbbefb632c639313691086d4 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 23 Aug 2018 16:11:23 +0200 Subject: [PATCH 03/10] JSON formatting and prefix removal --- src/core/expression/qgsexpression.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/expression/qgsexpression.cpp b/src/core/expression/qgsexpression.cpp index aecaa7c2fc8..2e4385d4b72 100644 --- a/src/core/expression/qgsexpression.cpp +++ b/src/core/expression/qgsexpression.cpp @@ -912,7 +912,7 @@ QString QgsExpression::formatPreviewString( const QVariant &value ) if ( separator.isEmpty() ) separator = QStringLiteral( ", " ); - mapStr.append( it.key() ).append( ": " ).append( formatPreviewString( it.value() ) ); + mapStr.append( QStringLiteral( "\"%1\": %2" ).arg( it.key(), formatPreviewString( it.value() ) ) ); if ( mapStr.length() > MAX_PREVIEW + 5 ) { mapStr = tr( "%1…" ).arg( mapStr.left( MAX_PREVIEW ) ); @@ -920,7 +920,7 @@ QString QgsExpression::formatPreviewString( const QVariant &value ) } } mapStr += QStringLiteral( " }" ); - return tr( "<map: %1>" ).arg( mapStr ); + return tr( "<%1>" ).arg( mapStr ); } else if ( value.type() == QVariant::List || value.type() == QVariant::StringList ) { @@ -941,7 +941,7 @@ QString QgsExpression::formatPreviewString( const QVariant &value ) } } listStr += QStringLiteral( " ]" ); - return tr( "<array: %1>" ).arg( listStr ); + return tr( "<%1>" ).arg( listStr ); } else { From 65fd187da8e722e8ef640977c5ada9871ecc0309 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 24 Aug 2018 05:52:15 +0200 Subject: [PATCH 04/10] Quote keys --- src/core/expression/qgsexpression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/expression/qgsexpression.cpp b/src/core/expression/qgsexpression.cpp index 2e4385d4b72..90b702d2f6d 100644 --- a/src/core/expression/qgsexpression.cpp +++ b/src/core/expression/qgsexpression.cpp @@ -912,7 +912,7 @@ QString QgsExpression::formatPreviewString( const QVariant &value ) if ( separator.isEmpty() ) separator = QStringLiteral( ", " ); - mapStr.append( QStringLiteral( "\"%1\": %2" ).arg( it.key(), formatPreviewString( it.value() ) ) ); + mapStr.append( QStringLiteral( "%1: %2" ).arg( quotedValue( it.key() ), formatPreviewString( it.value() ) ) ); if ( mapStr.length() > MAX_PREVIEW + 5 ) { mapStr = tr( "%1…" ).arg( mapStr.left( MAX_PREVIEW ) ); From 8e1aeda464cd478b8c6cea43d094835a1d1d025d Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 24 Aug 2018 06:08:35 +0200 Subject: [PATCH 05/10] More array and map expression formatting --- src/core/expression/qgsexpression.cpp | 31 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/core/expression/qgsexpression.cpp b/src/core/expression/qgsexpression.cpp index 90b702d2f6d..62b7216c003 100644 --- a/src/core/expression/qgsexpression.cpp +++ b/src/core/expression/qgsexpression.cpp @@ -903,45 +903,50 @@ QString QgsExpression::formatPreviewString( const QVariant &value ) } else if ( value.type() == QVariant::Map ) { - QString mapStr = QStringLiteral( "{ " ); + QString mapStr = QStringLiteral( "{" ); const QVariantMap map = value.toMap(); QString separator; for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it ) { mapStr.append( separator ); if ( separator.isEmpty() ) - separator = QStringLiteral( ", " ); + separator = QStringLiteral( "," ); - mapStr.append( QStringLiteral( "%1: %2" ).arg( quotedValue( it.key() ), formatPreviewString( it.value() ) ) ); - if ( mapStr.length() > MAX_PREVIEW + 5 ) + mapStr.append( QStringLiteral( " %1: %2" ).arg( quotedValue( it.key() ), formatPreviewString( it.value() ) ) ); + if ( mapStr.length() > MAX_PREVIEW - 3 ) { - mapStr = tr( "%1…" ).arg( mapStr.left( MAX_PREVIEW ) ); + mapStr = tr( "%1…" ).arg( mapStr.left( MAX_PREVIEW - 2 ) ); break; } } - mapStr += QStringLiteral( " }" ); - return tr( "<%1>" ).arg( mapStr ); + if ( !map.empty() ) + mapStr += QStringLiteral( " " ); + mapStr += QStringLiteral( "}" ); + return mapStr; } else if ( value.type() == QVariant::List || value.type() == QVariant::StringList ) { - QString listStr = QStringLiteral( "[ " ); + QString listStr = QStringLiteral( "[" ); const QVariantList list = value.toList(); QString separator; for ( const QVariant &arrayValue : list ) { listStr.append( separator ); if ( separator.isEmpty() ) - separator = QStringLiteral( ", " ); + separator = QStringLiteral( "," ); + listStr.append( " " ); listStr.append( formatPreviewString( arrayValue ) ); - if ( listStr.length() > MAX_PREVIEW + 5 ) + if ( listStr.length() > MAX_PREVIEW - 3 ) { - listStr = QString( tr( "%1…" ) ).arg( listStr.left( MAX_PREVIEW ) ); + listStr = QString( tr( "%1…" ) ).arg( listStr.left( MAX_PREVIEW - 2 ) ); break; } } - listStr += QStringLiteral( " ]" ); - return tr( "<%1>" ).arg( listStr ); + if ( !list.empty() ) + listStr += QStringLiteral( " " ); + listStr += QStringLiteral( "]" ); + return listStr; } else { From 70bf49a18da3cdc8ac0c8a560a6099749f774c56 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 24 Aug 2018 06:09:07 +0200 Subject: [PATCH 06/10] Adjust tests for array and map expression formatting --- tests/src/core/testqgsexpression.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/src/core/testqgsexpression.cpp b/tests/src/core/testqgsexpression.cpp index e2d21bf6ff9..41338f1f3bc 100644 --- a/tests/src/core/testqgsexpression.cpp +++ b/tests/src/core/testqgsexpression.cpp @@ -3108,19 +3108,19 @@ class TestQgsExpression: public QObject void test_formatPreviewString() { - QCOMPARE( QgsExpression::formatPreviewString( QVariant( "hello" ) ), QString( "'hello'" ) ); - QCOMPARE( QgsExpression::formatPreviewString( QVariant( QVariantMap() ) ), QString( "<map: >" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( "hello" ) ), QStringLiteral( "'hello'" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( QVariantMap() ) ), QStringLiteral( "{}" ) ); QVariantMap map; map[QStringLiteral( "1" )] = "One"; map[QStringLiteral( "2" )] = "Two"; - QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QString( "<map: 1: 'One', 2: 'Two'>" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ 1: 'One', 2: 'Two' }" ) ); map[QStringLiteral( "3" )] = "A very long string that is going to be truncated"; - QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QString( "<map: 1: 'One', 2: 'Two', 3: 'A very long string that is going to …>" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ 1: 'One', 2: 'Two', 3: 'A very long string that is going to … }" ) ); QVariantList list; list << 1 << 2 << 3; - QCOMPARE( QgsExpression::formatPreviewString( QVariant( list ) ), QString( "<array: 1, 2, 3>" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( list ) ), QStringLiteral( "[ 1, 2, 3 ]" ) ); QStringList stringList; stringList << QStringLiteral( "One" ) << QStringLiteral( "Two" ) << QStringLiteral( "A very long string that is going to be truncated" ); From 0274bc864556d6674a6ff1ac22ad4cff57606d9a Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 24 Aug 2018 08:11:07 +0200 Subject: [PATCH 07/10] More test fixes --- tests/src/core/testqgsexpression.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/src/core/testqgsexpression.cpp b/tests/src/core/testqgsexpression.cpp index 41338f1f3bc..d7589050aa0 100644 --- a/tests/src/core/testqgsexpression.cpp +++ b/tests/src/core/testqgsexpression.cpp @@ -3112,11 +3112,11 @@ class TestQgsExpression: public QObject QCOMPARE( QgsExpression::formatPreviewString( QVariant( QVariantMap() ) ), QStringLiteral( "{}" ) ); QVariantMap map; - map[QStringLiteral( "1" )] = "One"; - map[QStringLiteral( "2" )] = "Two"; + map[1] = "One"; + map[2] = "Two"; QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ 1: 'One', 2: 'Two' }" ) ); map[QStringLiteral( "3" )] = "A very long string that is going to be truncated"; - QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ 1: 'One', 2: 'Two', 3: 'A very long string that is going to … }" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ 1: 'One', 2: 'Two', '3': 'A very long string that is going to … }" ) ); QVariantList list; list << 1 << 2 << 3; @@ -3125,7 +3125,7 @@ class TestQgsExpression: public QObject QStringList stringList; stringList << QStringLiteral( "One" ) << QStringLiteral( "Two" ) << QStringLiteral( "A very long string that is going to be truncated" ); QCOMPARE( QgsExpression::formatPreviewString( QVariant( stringList ) ), - QString( "<array: 'One', 'Two', 'A very long string that is going to be trunca…>" ) ); + QStringLiteral( "[ 'One', 'Two', 'A very long string that is going to be trunca… ]" ) ); } }; From f9da59646248fb2c3f28b6d247fdabc7cebde1e8 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 24 Aug 2018 08:46:27 +0200 Subject: [PATCH 08/10] QVariantMaps always have string keys --- src/core/expression/qgsexpression.cpp | 2 +- tests/src/core/testqgsexpression.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/expression/qgsexpression.cpp b/src/core/expression/qgsexpression.cpp index 62b7216c003..c27cc23488a 100644 --- a/src/core/expression/qgsexpression.cpp +++ b/src/core/expression/qgsexpression.cpp @@ -912,7 +912,7 @@ QString QgsExpression::formatPreviewString( const QVariant &value ) if ( separator.isEmpty() ) separator = QStringLiteral( "," ); - mapStr.append( QStringLiteral( " %1: %2" ).arg( quotedValue( it.key() ), formatPreviewString( it.value() ) ) ); + mapStr.append( QStringLiteral( " '%1': %2" ).arg( it.key(), formatPreviewString( it.value() ) ) ); if ( mapStr.length() > MAX_PREVIEW - 3 ) { mapStr = tr( "%1…" ).arg( mapStr.left( MAX_PREVIEW - 2 ) ); diff --git a/tests/src/core/testqgsexpression.cpp b/tests/src/core/testqgsexpression.cpp index d7589050aa0..27e3baf8c12 100644 --- a/tests/src/core/testqgsexpression.cpp +++ b/tests/src/core/testqgsexpression.cpp @@ -3112,11 +3112,11 @@ class TestQgsExpression: public QObject QCOMPARE( QgsExpression::formatPreviewString( QVariant( QVariantMap() ) ), QStringLiteral( "{}" ) ); QVariantMap map; - map[1] = "One"; - map[2] = "Two"; - QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ 1: 'One', 2: 'Two' }" ) ); + map[QStringLiteral( "1" )] = "One"; + map[QStringLiteral( "2" )] = "Two"; + QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ '1': 'One', 2: 'Two' }" ) ); map[QStringLiteral( "3" )] = "A very long string that is going to be truncated"; - QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ 1: 'One', 2: 'Two', '3': 'A very long string that is going to … }" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ '1': 'One', '2': 'Two', '3': 'A very long string that is going to … }" ) ); QVariantList list; list << 1 << 2 << 3; From 7e63093987e37c84e3a4489c302840020b9e46b9 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 24 Aug 2018 11:30:09 +0200 Subject: [PATCH 09/10] Fix test --- tests/src/core/testqgsexpression.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/core/testqgsexpression.cpp b/tests/src/core/testqgsexpression.cpp index 27e3baf8c12..b867d897ad2 100644 --- a/tests/src/core/testqgsexpression.cpp +++ b/tests/src/core/testqgsexpression.cpp @@ -3114,9 +3114,9 @@ class TestQgsExpression: public QObject QVariantMap map; map[QStringLiteral( "1" )] = "One"; map[QStringLiteral( "2" )] = "Two"; - QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ '1': 'One', 2: 'Two' }" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ '1': 'One', '2': 'Two' }" ) ); map[QStringLiteral( "3" )] = "A very long string that is going to be truncated"; - QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ '1': 'One', '2': 'Two', '3': 'A very long string that is going to … }" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( map ) ), QStringLiteral( "{ '1': 'One', '2': 'Two', '3': 'A very long string that is… }" ) ); QVariantList list; list << 1 << 2 << 3; @@ -3125,7 +3125,7 @@ class TestQgsExpression: public QObject QStringList stringList; stringList << QStringLiteral( "One" ) << QStringLiteral( "Two" ) << QStringLiteral( "A very long string that is going to be truncated" ); QCOMPARE( QgsExpression::formatPreviewString( QVariant( stringList ) ), - QStringLiteral( "[ 'One', 'Two', 'A very long string that is going to be trunca… ]" ) ); + QStringLiteral( "[ 'One', 'Two', 'A very long string that is going to be tr… ]" ) ); } }; From ec4483a51a28763141b16c5fa7a3219de9972ef5 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 24 Aug 2018 14:04:27 +0200 Subject: [PATCH 10/10] Update map and array examples --- resources/function_help/json/array | 2 +- resources/function_help/json/array_append | 2 +- resources/function_help/json/array_cat | 2 +- resources/function_help/json/array_distinct | 2 +- resources/function_help/json/array_foreach | 4 ++-- resources/function_help/json/array_insert | 2 +- resources/function_help/json/array_prepend | 2 +- resources/function_help/json/array_remove_all | 2 +- resources/function_help/json/array_remove_at | 2 +- resources/function_help/json/array_reverse | 2 +- resources/function_help/json/array_slice | 16 ++++++++-------- resources/function_help/json/generate_series | 4 ++-- resources/function_help/json/map | 2 +- resources/function_help/json/map_akeys | 2 +- resources/function_help/json/map_avals | 2 +- resources/function_help/json/map_concat | 2 +- resources/function_help/json/map_delete | 2 +- resources/function_help/json/map_insert | 2 +- resources/function_help/json/regexp_matches | 4 ++-- resources/function_help/json/string_to_array | 4 ++-- 20 files changed, 31 insertions(+), 31 deletions(-) diff --git a/resources/function_help/json/array b/resources/function_help/json/array index ee71d768809..ee82b1ab630 100644 --- a/resources/function_help/json/array +++ b/resources/function_help/json/array @@ -7,6 +7,6 @@ {"arg":"value1", "syntaxOnly": true}, {"arg":"value2", "syntaxOnly": true}, {"arg":"value", "descOnly": true, "description":"a value"}], - "examples": [ { "expression":"array(2,10)", "returns":"array: 2, 10"} + "examples": [ { "expression":"array(2,10)", "returns":"[ 2, 10 ]"} ] } diff --git a/resources/function_help/json/array_append b/resources/function_help/json/array_append index 4da5a150087..e2865d8ffcf 100644 --- a/resources/function_help/json/array_append +++ b/resources/function_help/json/array_append @@ -4,5 +4,5 @@ "description": "Returns an array with the given value added at the end.", "arguments": [ {"arg":"array","description":"an array"}, {"arg":"value","description":"the value to add"}], - "examples": [ { "expression":"array_append(array(1,2,3),4)", "returns":"array: 1,2,3,4"}] + "examples": [ { "expression":"array_append(array(1,2,3),4)", "returns":"[ 1, 2, 3, 4 ]"}] } diff --git a/resources/function_help/json/array_cat b/resources/function_help/json/array_cat index 7529a3f7132..2a7be9e06e1 100644 --- a/resources/function_help/json/array_cat +++ b/resources/function_help/json/array_cat @@ -7,6 +7,6 @@ {"arg":"array1", "syntaxOnly": true}, {"arg":"array2", "syntaxOnly": true}, {"arg":"array", "descOnly": true, "description":"an array"}], - "examples": [ { "expression":"array_cat(array(1,2),array(2,3))", "returns":"array: 1,2,2,3"} + "examples": [ { "expression":"array_cat(array(1,2),array(2,3))", "returns":"[ 1, 2, 2, 3 ]"} ] } diff --git a/resources/function_help/json/array_distinct b/resources/function_help/json/array_distinct index 7dcf78c101d..a3147156a5b 100644 --- a/resources/function_help/json/array_distinct +++ b/resources/function_help/json/array_distinct @@ -4,6 +4,6 @@ "description": "Returns an array containing distinct values of the given array.", "arguments": [ {"arg":"array","description":"an array"}], - "examples": [ { "expression":"array_distinct(array(1,2,3,2,1))", "returns":"array: 1,2,3"} + "examples": [ { "expression":"array_distinct(array(1,2,3,2,1))", "returns":"[ 1, 2, 3 ]"} ] } diff --git a/resources/function_help/json/array_foreach b/resources/function_help/json/array_foreach index b1b84933cdd..ee27c572898 100644 --- a/resources/function_help/json/array_foreach +++ b/resources/function_help/json/array_foreach @@ -7,7 +7,7 @@ {"arg":"expression","description":"an expression to evaluate on each item. The variable `@element` will be replaced by the current value."} ], "examples": [ - { "expression": "array_foreach(array('a','b','c'),upper(@element))", "returns":"array: 'A', 'B', 'C'"}, - { "expression": "array_foreach(array(1,2,3),@element + 10)", "returns":"array: 11, 12, 13"} + { "expression": "array_foreach(array('a','b','c'),upper(@element))", "returns":"[ 'A', 'B', 'C' ]"}, + { "expression": "array_foreach(array(1,2,3),@element + 10)", "returns":"[ 11, 12, 13 ]"} ] } diff --git a/resources/function_help/json/array_insert b/resources/function_help/json/array_insert index dab0f495cca..8d5160549a2 100644 --- a/resources/function_help/json/array_insert +++ b/resources/function_help/json/array_insert @@ -5,5 +5,5 @@ "arguments": [ {"arg":"array","description":"an array"}, {"arg":"pos","description":"the position where to add (0 based)"}, {"arg":"value","description":"the value to add"}], - "examples": [ { "expression":"array_insert(array(1,2,3),1,100)", "returns":"array: 1,100,2,3"}] + "examples": [ { "expression":"array_insert(array(1,2,3),1,100)", "returns":"[ 1, 100, 2, 3 ]"}] } diff --git a/resources/function_help/json/array_prepend b/resources/function_help/json/array_prepend index a5d49c84cb6..8228d4f8216 100644 --- a/resources/function_help/json/array_prepend +++ b/resources/function_help/json/array_prepend @@ -4,5 +4,5 @@ "description": "Returns an array with the given value added at the beginning.", "arguments": [ {"arg":"array","description":"an array"}, {"arg":"value","description":"the value to add"}], - "examples": [ { "expression":"array_prepend(array(1,2,3),0)", "returns":"array: 0,1,2,3"}] + "examples": [ { "expression":"array_prepend(array(1,2,3),0)", "returns":"[ 0, 1, 2, 3 ]"}] } diff --git a/resources/function_help/json/array_remove_all b/resources/function_help/json/array_remove_all index de1882c0f96..47559bd5e28 100644 --- a/resources/function_help/json/array_remove_all +++ b/resources/function_help/json/array_remove_all @@ -4,5 +4,5 @@ "description": "Returns an array with all the entries of the given value removed.", "arguments": [ {"arg":"array","description":"an array"}, {"arg":"value","description":"the values to remove"}], - "examples": [ { "expression":"array_remove_all(array('a','b','c','b'),'b')", "returns":"array: 'a','c'"}] + "examples": [ { "expression":"array_remove_all(array('a','b','c','b'),'b')", "returns":"[ 'a', 'c' ]"}] } diff --git a/resources/function_help/json/array_remove_at b/resources/function_help/json/array_remove_at index 191af42c47e..08bcc9046ce 100644 --- a/resources/function_help/json/array_remove_at +++ b/resources/function_help/json/array_remove_at @@ -4,5 +4,5 @@ "description": "Returns an array with the given index removed.", "arguments": [ {"arg":"array","description":"an array"}, {"arg":"pos","description":"the position to remove (0 based)"}], - "examples": [ { "expression":"array_remove_at(array(1,2,3),1)", "returns":"array: 1,3"}] + "examples": [ { "expression":"array_remove_at(array(1,2,3),1)", "returns":"[ 1, 3 ]"}] } diff --git a/resources/function_help/json/array_reverse b/resources/function_help/json/array_reverse index 06e64dc3186..d84d6c9e83d 100644 --- a/resources/function_help/json/array_reverse +++ b/resources/function_help/json/array_reverse @@ -3,5 +3,5 @@ "type": "function", "description": "Returns the given array with array values in reversed order.", "arguments": [ {"arg":"array","description":"an array"} ], - "examples": [ { "expression":"array_reverse(array(2,4,0,10))", "returns":"array: 10,0,4,2"}] + "examples": [ { "expression":"array_reverse(array(2,4,0,10))", "returns":"[ 10, 0, 4, 2 ]"}] } diff --git a/resources/function_help/json/array_slice b/resources/function_help/json/array_slice index 6e52117bd94..c527c7bed21 100644 --- a/resources/function_help/json/array_slice +++ b/resources/function_help/json/array_slice @@ -17,35 +17,35 @@ ], "examples": [{ "expression": "array_slice(array(1,2,3,4,5),0,3)", - "returns": "array: 1,2,3,4" + "returns": "[ 1, 2, 3, 4 ]" }, { "expression": "array_slice(array(1,2,3,4,5),0,-1)", - "returns": "array: 1,2,3,4,5" + "returns": "[ 1, 2, 3, 4, 5 ]" }, { "expression": "array_slice(array(1,2,3,4,5),-5,-1)", - "returns": "array: 1,2,3,4,5" + "returns": "[ 1, 2, 3, 4, 5 ]" }, { "expression": "array_slice(array(1,2,3,4,5),0,0)", - "returns": "array: 1" + "returns": "[ 1 ]" }, { "expression": "array_slice(array(1,2,3,4,5),-2,-1)", - "returns": "array: 4,5" + "returns": "[ 4, 5 ]" }, { "expression": "array_slice(array(1,2,3,4,5),-1,-1)", - "returns": "array: 5" + "returns": "[ 5 ]" }, { "expression": "array_slice(array('Dufour','Valmiera','Chugiak','Brighton'),1,2)", - "returns": "array: 'Valmiera','Chugiak'" + "returns": "[ 'Valmiera', 'Chugiak' ]" }, { "expression": "array_slice(array_slice(array('Dufour','Valmiera','Chugiak','Brighton'),-2,-1)", - "returns": "array: 'Chugiak','Brighton'" + "returns": "[ 'Chugiak', 'Brighton' ]" } ] } diff --git a/resources/function_help/json/generate_series b/resources/function_help/json/generate_series index e366aadd30c..fc790566fee 100644 --- a/resources/function_help/json/generate_series +++ b/resources/function_help/json/generate_series @@ -7,7 +7,7 @@ {"arg":"stop", "description":"value that ends the sequence once reached"}, {"arg":"step","optional":true,"default":"1","description":"value used as the increment between values"} ], - "examples": [ { "expression":"generate_series('1,5)", "returns":"array: '1', '2', '3', '4', '5'"}, - { "expression":"generate_series('5,1,-1)", "returns":"array: '5', '4', '3', '2', '1'"} + "examples": [ { "expression":"generate_series('1,5)", "returns":"[ 1, 2, 3, 4, 5 ]"}, + { "expression":"generate_series('5,1,-1)", "returns":"[ 5, 4, 3, 2, 1 ]"} ] } diff --git a/resources/function_help/json/map b/resources/function_help/json/map index a3638fce8cc..6691c0945cb 100644 --- a/resources/function_help/json/map +++ b/resources/function_help/json/map @@ -10,6 +10,6 @@ {"arg":"value2", "syntaxOnly": true}, {"arg":"key", "descOnly": true, "description":"a key (string)"}, {"arg":"value", "descOnly": true, "description":"a value"}], - "examples": [ { "expression":"map('1','one','2', 'two')", "returns":"map: 1: 'one', 2: 'two'"} + "examples": [ { "expression":"map('1','one','2', 'two')", "returns":"{ '1': 'one', '2': 'two' }"} ] } diff --git a/resources/function_help/json/map_akeys b/resources/function_help/json/map_akeys index b1904a78f3a..d309a0b5fcd 100644 --- a/resources/function_help/json/map_akeys +++ b/resources/function_help/json/map_akeys @@ -3,5 +3,5 @@ "type": "function", "description": "Returns all the keys of a map as an array.", "arguments": [ {"arg":"map","description":"a map"}], - "examples": [ { "expression":"map_akeys(map('1','one','2','two'))", "returns":"array: '1', '2'"}] + "examples": [ { "expression":"map_akeys(map('1','one','2','two'))", "returns":"[ '1', '2' ]"}] } diff --git a/resources/function_help/json/map_avals b/resources/function_help/json/map_avals index 4ea549a3a10..266c8162405 100644 --- a/resources/function_help/json/map_avals +++ b/resources/function_help/json/map_avals @@ -3,5 +3,5 @@ "type": "function", "description": "Returns all the values of a map as an array.", "arguments": [ {"arg":"map","description":"a map"}], - "examples": [ { "expression":"map_avals(map('1','one','2','two'))", "returns":"array: 'one', 'two'"}] + "examples": [ { "expression":"map_avals(map('1','one','2','two'))", "returns":"[ 'one', 'two' ]"}] } diff --git a/resources/function_help/json/map_concat b/resources/function_help/json/map_concat index 514e51d643d..bebb5b3ec44 100644 --- a/resources/function_help/json/map_concat +++ b/resources/function_help/json/map_concat @@ -7,6 +7,6 @@ {"arg":"map1", "syntaxOnly": true}, {"arg":"map2", "syntaxOnly": true}, {"arg":"map", "descOnly": true, "description":"a map"}], - "examples": [ { "expression":"map_concat(map('1','one', '2','overridden'),map('2','two', '3','three'))", "returns":"map: 1: 'one, 2: 'two', 3: 'three'"} + "examples": [ { "expression":"map_concat(map('1','one', '2','overridden'),map('2','two', '3','three'))", "returns":"{ '1': 'one, '2': 'two', '3': 'three' }"} ] } diff --git a/resources/function_help/json/map_delete b/resources/function_help/json/map_delete index b9a14f00101..719af39b3d9 100644 --- a/resources/function_help/json/map_delete +++ b/resources/function_help/json/map_delete @@ -4,5 +4,5 @@ "description": "Returns a map with the given key and its corresponding value deleted.", "arguments": [ {"arg":"map","description":"a map"}, {"arg":"key","description":"the key to delete"}], - "examples": [ { "expression":"map_delete(map('1','one','2','two'),'2')", "returns":"map: 1: 'one'"}] + "examples": [ { "expression":"map_delete(map('1','one','2','two'),'2')", "returns":"{ '1': 'one' }"}] } diff --git a/resources/function_help/json/map_insert b/resources/function_help/json/map_insert index 0d1fc47f9d1..235558dcf8d 100644 --- a/resources/function_help/json/map_insert +++ b/resources/function_help/json/map_insert @@ -5,5 +5,5 @@ "arguments": [ {"arg":"map","description":"a map"}, {"arg":"key","description":"the key to add"}, {"arg":"value","description":"the value to add"}], - "examples": [ { "expression":"map_insert(map('1','one'),'3','three')", "returns":"map: 1: 'one', 3: 'three'"}] + "examples": [ { "expression":"map_insert(map('1','one'),'3','three')", "returns":"{ '1': 'one', '3': 'three' }"}] } diff --git a/resources/function_help/json/regexp_matches b/resources/function_help/json/regexp_matches index 68f914564d0..ab223f8469b 100644 --- a/resources/function_help/json/regexp_matches +++ b/resources/function_help/json/regexp_matches @@ -6,7 +6,7 @@ {"arg":"string", "description":"the string to capture groups from against the regular expression"}, {"arg":"regex","description":"the regular expression used to capture groups"}, {"arg":"empty_value","optional":true,"default":"''","description":"the optional string to use as replacement for empty (zero length) matches"}], - "examples": [ { "expression":"regexp_matches('QGIS=>rocks','(.*)=>(.*)')", "returns":"array: 'QGIS', 'rocks'"}, - { "expression":"regexp_matches('key=>','(.*)=>(.*)','empty value')", "returns":"array: 'key', 'empty value'"} + "examples": [ { "expression":"regexp_matches('QGIS=>rocks','(.*)=>(.*)')", "returns":"[ 'QGIS', 'rocks' ]"}, + { "expression":"regexp_matches('key=>','(.*)=>(.*)','empty value')", "returns":"[ 'key', 'empty value' ]"} ] } diff --git a/resources/function_help/json/string_to_array b/resources/function_help/json/string_to_array index 31e0ffbc9ab..df89d15f4b5 100644 --- a/resources/function_help/json/string_to_array +++ b/resources/function_help/json/string_to_array @@ -6,7 +6,7 @@ {"arg":"string", "description":"the input string"}, {"arg":"delimiter","optional":true,"default":"','","description":"the string delimiter used to split the input string"}, {"arg":"empty_value","optional":true,"default":"''","description":"the optional string to use as replacement for empty (zero length) matches"}], - "examples": [ { "expression":"string_to_array('1,2,3',',')", "returns":"array: '1', '2', '3'"}, - { "expression":"string_to_array('1,,3',',','0')", "returns":"array: '1', '0', '3'"} + "examples": [ { "expression":"string_to_array('1,2,3',',')", "returns":"[ '1', '2', '3' ]"}, + { "expression":"string_to_array('1,,3',',','0')", "returns":"[ '1', '0', '3' ]"} ] }