@@ -306,7 +306,7 @@ def test_feature_to_json(self):
306
306
'a_date_field' : 1646352000000 ,
307
307
'a_double_field' : 5.5 ,
308
308
'a_int_field' : 5 ,
309
- 'a_string_field' : 'my string value ' ,
309
+ 'a_string_field' : 'my%20string%20value ' ,
310
310
'a_null_value' : None },
311
311
'geometry' : {'x' : 1.0 , 'y' : 2.0 }})
312
312
# without geometry
@@ -316,7 +316,7 @@ def test_feature_to_json(self):
316
316
'a_date_field' : 1646352000000 ,
317
317
'a_double_field' : 5.5 ,
318
318
'a_int_field' : 5 ,
319
- 'a_string_field' : 'my string value ' ,
319
+ 'a_string_field' : 'my%20string%20value ' ,
320
320
'a_null_value' : None }})
321
321
# without attributes
322
322
context .setObjectIdFieldName ('a_int_field' )
@@ -325,6 +325,19 @@ def test_feature_to_json(self):
325
325
'a_int_field' : 5 },
326
326
'geometry' : {'x' : 1.0 , 'y' : 2.0 }})
327
327
328
+ # with special characters
329
+
330
+ attributes [0 ] = 'aaa" , . - ; : ä ö ü è é à ? + &'
331
+ test_feature .setAttributes (attributes )
332
+ res = QgsArcGisRestUtils .featureToJson (test_feature , context , flags = QgsArcGisRestUtils .FeatureToJsonFlags (QgsArcGisRestUtils .FeatureToJsonFlag .IncludeNonObjectIdAttributes ))
333
+ self .assertEqual (res , {'attributes' : {'a_boolean_field' : True ,
334
+ 'a_datetime_field' : 1646395994000 ,
335
+ 'a_date_field' : 1646352000000 ,
336
+ 'a_double_field' : 5.5 ,
337
+ 'a_int_field' : 5 ,
338
+ 'a_string_field' : 'aaa%22%20%2C%20.%20-%20%3B%20%3A%20%C3%A4%20%C3%B6%20%C3%BC%20%C3%A8%20%C3%A9%20%C3%A0%20%3F%20%2B%20%26' ,
339
+ 'a_null_value' : None }})
340
+
328
341
def test_field_to_json (self ):
329
342
field = QgsField ('my name' , QVariant .LongLong )
330
343
field .setAlias ('my alias' )
0 commit comments