I try to parse json string from glosbe witch is free tool dictionary and I could not understand where I am doing wrong .
I am getting error ..object should be first initialized list. I tried to initialize the components but no result. Sometimes it works sometimes not.
I use the folowing code
I do a http utils job to retrive job.getstring from
http://glosbe.com/gapi/translate?from=ron&dest=eng&format=json&phrase=casa
Sub parse_translation(detail As String)
'http://glosbe.com/gapi/translate?from=ron&dest=eng&format=json&phrase=casa
Dim sb As StringBuilder
sb.Initialize
Dim parser As JSONParser
parser.Initialize(detail)
Dim root As Map = parser.NextObject
'Dim authors As Map = root.Get("authors")
'Dim 2698 As Map = authors.Get("2698")
'Dim id As Int = 2698.Get("id")
'Dim U As String = 2698.Get("U")
'Dim N As String = 2698.Get("N")
'Dim 1 As Map = authors.Get("1")
'Dim id As Int = 1.Get("id")
'Dim U As String = 1.Get("U")
'Dim N As String = 1.Get("N")
'Dim 2877 As Map = authors.Get("2877")
'Dim id As Int = 2877.Get("id")
'Dim U As String = 2877.Get("U")
'Dim N As String = 2877.Get("N")
'Dim 25018 As Map = authors.Get("25018")
'Dim id As Int = 25018.Get("id")
'Dim U As String = 25018.Get("U")
'Dim N As String = 25018.Get("N")
'Dim 25115 As Map = authors.Get("25115")
'Dim id As Int = 25115.Get("id")
'Dim U As String = 25115.Get("U")
'Dim N As String = 25115.Get("N")
'Dim result As String = root.Get("result")
'Dim dest As String = root.Get("dest")
'Dim phrase As String = root.Get("phrase")
'Dim from As String = root.Get("from")
Dim tuc As List = root.Get("tuc")
For Each coltuc As Map In tuc
' Dim authors As List = coltuc.Get("authors")
' For Each colauthors As Int In authors
' Next
'
' Dim meaningId As String = coltuc.Get("meaningId")
' Dim meanings As List = coltuc.Get("meanings")
' For Each colmeanings As Map In meanings
' Dim text As String = colmeanings.Get("text")
' Dim language As String = colmeanings.Get("language")
' Next
'
Dim phrase As Map = coltuc.Get("phrase")
Dim text As String = phrase.Get("text")
Dim language As String = phrase.Get("language")
sb.Append(text).Append(CRLF)
msgbox(sb.tostring,"Glosbe Dictionary")
Next
end sub
** Service (httputils2service) Create **
** Service (httputils2service) Start **
JobName = job_tr, Success = true
main_parse_translation (java line: 5082)
java.lang.RuntimeException: Object should first be initialized (List).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:45)
at anywheresoftware.b4a.objects.collections.List.getSize(List.java:120)
at hs.easy.romt.main._parse_translation(main.java:5082)
at hs.easy.romt.main._jobdone(main.java:4348)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:885)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Object should first be initialized (List).