#1 2018-07-05 14:43:16

jars
Member
Registered: 2015-05-15
Posts: 29

Need help to extract message from json

Hi,
the same service can return the error message in 2 different ways, one of them is an array. How can you distinguish and display the "errorText" message of each one.

a) '{"errorCode": 400, "errorText": "There are ongoing communications}}'
b) '{"errorCode": 400, "errorText": "[{\" ACTIVITY_GROUP \ ": \" A \ ", \" MODEL \ ": \" HELLO \ ", \" STATUS \ ": 0}, \ r \ n {\ "ACTIVITY_GROUP \": \ "B \", \ "MODEL \": \ "SALE \", \ "STATUS \": 0}] \ n "} '


Thanks in advance.

Offline

#2 2018-07-05 16:15:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,240
Website

Re: Need help to extract message from json

It is depending on the service implementation, for sure.
I guess that the b) case was not an error?

Sounds like a misconception on the service code.
You may post some code, but please not directly in the forum but as external link - see https://synopse.info/forum/misc.php?action=rules

For detailed returned content, uses a method-based service which allows to customized the returned content.
Or use a TServiceCustomAnswer function for interface-based service - but you will loose most of the interest of interface-based services.

Offline

Board footer

Powered by FluxBB