Does the sequence of the values matter in a JSON object?

Does the sequence of the values matter in a JSON object?

  

Hi there,

i got response a JSon from web service like this:

{
  "xxxx": [
    {
      "customer": [
        {
          "score": "0",
          "crn": "0000",
          "cif": "0000",
          "idNo": "abc",
          "accountType": [
            "eee"
          ]
        }
      ]
    },
    {
      "customer": [
        {
          "score": "1",
          "idNo": "def",
          "accountType": [
            "aaa"
          ],
          "crn": "0000",
          "cif": "0000",
        }
      ]
    }
  ]
}

# the sequence of the name-value pairs are different

# in test tab, i got the response above

# when i try to call from web service (server action-after i create the REST), i only got the first  customer

My question:

1. Is ordering is significant in Outsystems REST  

2. or do i create a wrong web service? 

regards and thank you

Solution

Hello Box,

As far as I can tell, the order shouldn't be significant (at least based on the JSON specification).

Are you sure that you are passing exactly the same parameters both inthe test as well as when consuming the web service in logic?

Also, how is this web service being created? Is an OutSystems web service or is a third part thing?

Cheers.

Solution

Hi Box,

I am also agree with the Edurado comment, Since json is an object and always stored values in Key,Value pair. Order should not be an issue. Are you paring in a same structure as json is returning ?

Sachin

Hi Box,


I created a mock REST returning your JSON and tried to call it from OutSystems.

Everything worked OK, all data was returned. How are you parsing the result?



Hi BOX ,

Sequencing should not be an issue in JSON , when you consumed this API did you try a test run in same window. You can also check in OnResponse method of Rest API to check what exactly is being returned by the API.



Regards

-PJ-


hi there,

Thank you:

1. Edu: it is third party web service, called from OS Rest

2. Sachin: i use Outsystem tools to generate the response structures, and it gives the first customer info structure (of course in a list).

3. Torres: i'll recheck it again... and when in a test tab, it returns both customers, but when i call from REST, it only return one.. i'll try to hard code this evening.. thank you

4. In On Respond, it only returns index 0, so only 1 customer. I am wondering, where can i find the "Raw" results, is On Respond happened after Oustsystem parse the correct respond or before that. 

I mean say that the respond is two customers, but because of different order, then it only return one - that is match with the structure?


thank you sirs, 

regards  

Box wrote:

hi there,

Thank you:

1. Edu: it is third party web service, called from OS Rest

2. Sachin: i use Outsystem tools to generate the response structures, and it gives the first customer info structure (of course in a list).

3. Torres: i'll recheck it again... and when in a test tab, it returns both customers, but when i call from REST, it only return one.. i'll try to hard code this evening.. thank you

4. In On Respond, it only returns index 0, so only 1 customer. I am wondering, where can i find the "Raw" results, is On Respond happened after Oustsystem parse the correct respond or before that. 

I mean say that the respond is two customers, but because of different order, then it only return one - that is match with the structure?


thank you sirs, 

regards  

Hello Box,

Like I said, the order of the fields should not influence the result of the parsing.
I would say that you are doing something different between the test and the code.

If you turno on the extra log information you will be able to see exactly the response that is being provided by the ws.
The OnAfterResponse method also allows you to look to the raw response before the parsing made by OutSystems.

Cheers.

Already tested this evening and the request is rather different. The result is correct that the sequence has no effect. Thank you very much, Sirs.

regards