In the post #33 https://www.b4x.com/android/forum/threads/android-json-tutorial.6923/page-2
the user "sioconcept" wrote
However I tried to parse the 18 MB "c.json" file and got the error
and this is a very very small part of the "c.json" file
How do you explain all this?
Thanks for the attention !
the user "sioconcept" wrote
and Erel answeredIs there a limit size of the JSON string?
There is no hard limit.
However I tried to parse the 18 MB "c.json" file and got the error
This is the simple codejava.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack available
B4X:
Dim List1 As List
Dim JSON As JSONParser
JSON.Initialize(File.ReadString(File.DirAssets, "c.json"))
List1.Initialize
List1 = JSON.NextArray
Dim M As Map
M = List1.Get(0)
Dim loc As Map
loc = M.Get("id")
For i = 0 To 50 ' loc.Size - 1
Dim Longitude As Double
Dim Latitude As Double
Dim name As String
Longitude = loc.Get ("lon")
Latitude = loc.Get ("lat")
name = loc.Get ("name")
Log(name & " " & Latitude & " " & Longitude)
Next
and this is a very very small part of the "c.json" file
{
"id": 3177841,
"coord": {
"lon": 9.66826,
"lat": 45.358768
},
"country": "IT",
"geoname": {
"cl": "P",
"code": "PPLA3",
"parent": 6540640
},
"name": "Crema",
"stat": {
"level": 1.0,
"population": 32981
},
"stations": [
{
"id": 5794,
"dist": 34,
"kf": 1
},
{
"id": 5800,
"dist": 31,
"kf": 1
},
{
"id": 5820,
"dist": 40,
"kf": 1
},
{
"id": 8977,
"dist": 0,
"kf": 1
},
{
"id": 9552,
"dist": 13,
"kf": 1
},
{
"id": 9798,
"dist": 34,
"kf": 1
},
{
"id": 10222,
"dist": 39,
"kf": 1
},
{
"id": 10368,
"dist": 39,
"kf": 1
},
{
"id": 10799,
"dist": 44,
"kf": 1
},
{
"id": 28814,
"dist": 42,
"kf": 1
},
{
"id": 29222,
"dist": 0,
"kf": 1
},
{
"id": 32018,
"dist": 18,
"kf": 1
},
{
"id": 32561,
"dist": 39,
"kf": 1
},
{
"id": 34103,
"dist": 43,
"kf": 1
},
{
"id": 35260,
"dist": 15,
"kf": 1
},
{
"id": 35663,
"dist": 39,
"kf": 1
}
],
"zoom": 10
},
{
"id": 3177924,
"coord": {
"lon": 8.18172,
"lat": 45.57386
},
"country": "IT",
"geoname": {
"cl": "P",
"code": "PPLA3",
"parent": 6540883
},
"langs": [
{
"de": "Cossato"
},
{
"en": "Cossato"
},
{
"eo": "Cossato"
},
{
"fr": "Cossato"
},
{
"it": "Cossato"
},
{
"link": "http://en.wikipedia.org/wiki/Cossato"
},
{
"nap": "Cossato"
},
{
"nl": "Cossato"
},
{
"pl": "Cossato"
},
{
"pt": "Cossato"
}
],
"name": "Cossato",
"stat": {
"level": 1.0,
"population": 15266
},
"stations": [
{
"id": 5792,
"dist": 43,
"kf": 1
},
{
"id": 30106,
"dist": 47,
"kf": 1
},
{
"id": 30420,
"dist": 48,
"kf": 1
},
{
"id": 32877,
"dist": 48,
"kf": 1
},
{
"id": 33359,
"dist": 36,
"kf": 1
},
{
"id": 33573,
"dist": 47,
"kf": 1
},
{
"id": 34361,
"dist": 27,
"kf": 1
},
{
"id": 34492,
"dist": 46,
"kf": 1
},
{
"id": 35332,
"dist": 32,
"kf": 1
},
{
"id": 36136,
"dist": 35,
"kf": 1
}
],
"zoom": 11
},
How do you explain all this?
Thanks for the attention !