<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
Hi list,<br>
<br>
I am parsing a larger (about 200k characters) GeoJSON
FeatureCollection string via QgsJsonUtils.stringToFields(). <br>
It contains polygon features, each with many coordinate pairs. <br>
Despite the string being valid GeoJSON, no fields are returned.<br>
<br>
However, if I save the string to a .geojson file and open it as
vector layer, it opens with the attribute fields.<br>
<br>
I am working with both QGIS 3.10.8 and 3.14.1 on Ubuntu.<br>
Here is a simplified example of the GeoJSON structure:<br>
<br>
{<br>
"features": [<br>
{<br>
"geometry": {<br>
"coordinates": [<br>
[<br>
[<br>
0.0,<br>
1.0<br>
],<br>
.<br>
.<br>
.<br>
[<br>
0.0,<br>
1.0<br>
]<br>
]<br>
],<br>
"type": "Polygon"<br>
},<br>
"id": "abcd",<br>
"type": "Feature",<br>
"properties": {<br>
"attrib_a": "a text",<br>
"attrib_b": 1<br>
}<br>
}<br>
],<br>
"type": "FeatureCollection"<br>
}<br>
<br>
<br>
I found that if I do either of the below steps before calling
QgsJsonUtils.stringToFields(), it does return the fields:<br>
<ul>
<li> significantly reduce the number of coordinate pairs<br>
</li>
<li> Change the order of objects so that "type" is ahead of
"geometry" in the features. <br>
</li>
</ul>
<p>I looked at the unit tests of QgsJsonUtils but only short geojson
strings are tested there..</p>
<p>So it looks like large geometry objects in the GeoJSON feature
would prevent reading its fields... unless "type" is parsed before
them?</p>
<p>Is this buggy behavior? Or am I missing something?<br>
</p>
<p>Should I open an issue on GitHub?<br>
</p>
<br>
<br>
Best regards,<br>
Aron <br>
</body>
</html>