wrong Json format B4J

35 Views Asked by At

This is my JSON fromat on endpoints.txt

[
    {
        "host": "https://xxx.xxx.xxx.xxx:8443/api/v1/namespaces/sf7dev/pods",
        "name": "OKD 1",
        "token": "My token"
    }
]

This is my code:

Sub tickInterval_tick
    time.Enabled= False
    Dim endpointList As List
    endpointList = File.ReadList(File.DirApp, "endpoints.txt")
    Dim parser As JSONParser

    For t = 0 To endpointList.Size - 1
        parser.Initialize(endpointList.Get(t))
        Dim endpointMap As Map = parser.NextObject
        ContainerReady(endpointMap.Get("name"), endpointMap.Get("host"), endpointMap.Get("token"))
    Next
    time.Enabled= True
End Sub

Error occured on this line:

Dim endpointMap As Map = parser.NextObject

It says:

org.json.JSONException: Unterminated array at character 1 of ["

Can you guys help me? I don't get it what was wrong with my JSON format.

Thanks a lot.

I tried to execute this code:

Sub tickInterval_tick
    time.Enabled= False
    Dim endpointList As List
    endpointList = File.ReadList(File.DirApp, "endpoints.txt")
    Dim parser As JSONParser

    For t = 0 To endpointList.Size - 1
        parser.Initialize(endpointList.Get(t))
        Dim endpointMap As Map = parser.NextObject
        ContainerReady(endpointMap.Get("name"), endpointMap.Get("host"), endpointMap.Get("token"))
    Next
    time.Enabled= True
End Sub

and my expecatation it can read and process my endpoints.txt

0

There are 0 best solutions below