hello everyone hopefully everything is well, I have a jsonarray in my android studio java Library and i am trying to pass it as a parameter.
I thought that it is better to pass it as string like following
then on My B4a app I do
i got this output when i do log participant parameter
then this error
I thought that it is better to pass it as string like following
Java:
if (Newparticipant != null && Newparticipant.length() > 0) {
BA.Log("------New User-----");
rtcEvents.onNewParticipant(Newparticipant.toString());
}
// then i call it in b4a event like following
public void onNewParticipant(String participantJson) {
B4a.raiseEventFromDifferentThread(Globalunit.this,null,0,eventName+"_onnewparticipant", false, new Object[] {participantJson});
}
then on My B4a app I do
B4X:
Sub MywsClient_onNewParticipant(participant As String)
Dim parser As JSONParser
parser.Initialize(participant)
Dim NewUser As Map = parser.NextObject
Log(NewUser.Size)
End Sub
i got this output when i do log participant parameter
B4X:
[{"id":2302024264352889,"display":"B4xUser","setup":false,"muted":false}]
then this error
it says that Json expected which i already passed Jsonarray to string. what is my mistake ?[{"id":2302024264352889,"display":"B4xUser","setup":false,"muted":false}]
myservice_mywsclient_onnewparticipant (java line: 156)
java.lang.RuntimeException: JSON Object expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextObject(JSONParser.java:67)
at b4a.example.myservice._mywsclient_onnewparticipant(myservice.java:156)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8387)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
java.lang.RuntimeException: java.lang.RuntimeException: JSON Object expected.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:250)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8387)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
Caused by: java.lang.RuntimeException: JSON Object expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextObject(JSONParser.java:67)
at b4a.example.myservice._mywsclient_onnewparticipant(myservice.java:156)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
... 8 more