Ticket Created
over 3 years ago

CIQQA-903

Processing JSON with missing root

The following (which is valid JSON) returns  INVALID_HTTP_BODY_IN_NETWORK_RESPONSE.

It's missing the root node but is still valid JSON. Missing the root node is fairy common. So, it should be able to be processed by IQ.

[
{
"name":"aaaa"
},
{
"name":"bbbb"
}
]

The following  is not missing the root node (and works).

 

{
"list" : [
{
"name":"aaaa"
},
{
"name":"bbbb"
}
]
}

Parents
  • > Maybe it's valid json but sdk need name for dictionary key so error...

    Yes. The makeWebRequest functionality requires the incoming JSON to be a JSON Object (a MonkeyC dictionary). This has come up before, several times. We have not changed the behavior thus far, so I have some doubt that we'd change it unless there was a really good motivation.

    > Why can't the key be an empty string?

    The data that doesn't work that is shown above is a JSON Array, and as I've just explained we expect the web service to provide a JSON Object (a Dictionary). A JSON Object with an empty key is *not* the same as a JSON Array. Example..

    # this is a JSON array
    
    [
      {
        "name":"aaaa"
      },
      {
        "name":"bbbb"
      }
    ]
    
    
    # this is a JSON dictionary with an empty string as a key
    {
      "": [
            {
              "name":"aaaa"
            },
            {
              "name":"bbbb"
            }
      ]
    ]
    

    If the incoming JSON is a valid JSON Object (Dictionary), we should be able to process it.

Comment
  • > Maybe it's valid json but sdk need name for dictionary key so error...

    Yes. The makeWebRequest functionality requires the incoming JSON to be a JSON Object (a MonkeyC dictionary). This has come up before, several times. We have not changed the behavior thus far, so I have some doubt that we'd change it unless there was a really good motivation.

    > Why can't the key be an empty string?

    The data that doesn't work that is shown above is a JSON Array, and as I've just explained we expect the web service to provide a JSON Object (a Dictionary). A JSON Object with an empty key is *not* the same as a JSON Array. Example..

    # this is a JSON array
    
    [
      {
        "name":"aaaa"
      },
      {
        "name":"bbbb"
      }
    ]
    
    
    # this is a JSON dictionary with an empty string as a key
    {
      "": [
            {
              "name":"aaaa"
            },
            {
              "name":"bbbb"
            }
      ]
    ]
    

    If the incoming JSON is a valid JSON Object (Dictionary), we should be able to process it.

Children
No Data