Mailing List Archive

UCCX REST JSON Array Response to String
This is probably something Anthony knows off the top of his head but at
least we'll get his answer archived.

I've got a UCCX Script doing a REST Call and the response JSON is actually
an array (indicated by the square brackets) even though it's only one
response. The resulting String looks like this:
U"[{\"status\":\"Delivered\"}]"

Converting this into a Document then JSON Document seems to not work
properly because of this bracket issue. The JSON Document ends up looking
like this:
TEXT[[{\"status\":\"Delivered\"}]]"

The GET JSON Document Data step then fails to find anything using the
JSONPath.

To work around it, we used substring to remove the set of square brackets
around the original response string before converting to a Doc which works
and resolves the issue but I'm thinking there's gotta be a better
solution.

I imagine many JSON responses are probably going to contain arrays. In
this case, we're always getting a single result but I can imagine this
would be an issue where the REST step actually comes back with multiple
items in the array.

Any ideas?
Re: UCCX REST JSON Array Response to String [ In reply to ]
We need to see how you're converting, and how you're querying to give you
meaningful help.

Quick 5 second POC using your input string:

[image: image.png]

On Thu, Jul 30, 2020 at 2:29 PM Brian Meade <bmeade90@vt.edu> wrote:

> This is probably something Anthony knows off the top of his head but at
> least we'll get his answer archived.
>
> I've got a UCCX Script doing a REST Call and the response JSON is actually
> an array (indicated by the square brackets) even though it's only one
> response. The resulting String looks like this:
> U"[{\"status\":\"Delivered\"}]"
>
> Converting this into a Document then JSON Document seems to not work
> properly because of this bracket issue. The JSON Document ends up looking
> like this:
> TEXT[[{\"status\":\"Delivered\"}]]"
>
> The GET JSON Document Data step then fails to find anything using the
> JSONPath.
>
> To work around it, we used substring to remove the set of square brackets
> around the original response string before converting to a Doc which works
> and resolves the issue but I'm thinking there's gotta be a better
> solution.
>
> I imagine many JSON responses are probably going to contain arrays. In
> this case, we're always getting a single result but I can imagine this
> would be an issue where the REST step actually comes back with multiple
> items in the array.
>
> Any ideas?
> _______________________________________________
> cisco-voip mailing list
> cisco-voip@puck.nether.net
> https://puck.nether.net/mailman/listinfo/cisco-voip
>
Re: UCCX REST JSON Array Response to String [ In reply to ]
Tanner,

It looks like your solution should work. I had tried a couple of different
ways of trying to get the status from the first Element. I'll give that a
try with your JSONPath.

Thanks,
Brian Meade

On Thu, Jul 30, 2020 at 6:17 PM Tanner Ezell <tanner.ezell@gmail.com> wrote:

> We need to see how you're converting, and how you're querying to give you
> meaningful help.
>
> Quick 5 second POC using your input string:
>
> [image: image.png]
>
> On Thu, Jul 30, 2020 at 2:29 PM Brian Meade <bmeade90@vt.edu> wrote:
>
>> This is probably something Anthony knows off the top of his head but at
>> least we'll get his answer archived.
>>
>> I've got a UCCX Script doing a REST Call and the response JSON is
>> actually an array (indicated by the square brackets) even though it's only
>> one response. The resulting String looks like this:
>> U"[{\"status\":\"Delivered\"}]"
>>
>> Converting this into a Document then JSON Document seems to not work
>> properly because of this bracket issue. The JSON Document ends up looking
>> like this:
>> TEXT[[{\"status\":\"Delivered\"}]]"
>>
>> The GET JSON Document Data step then fails to find anything using the
>> JSONPath.
>>
>> To work around it, we used substring to remove the set of square brackets
>> around the original response string before converting to a Doc which works
>> and resolves the issue but I'm thinking there's gotta be a better
>> solution.
>>
>> I imagine many JSON responses are probably going to contain arrays. In
>> this case, we're always getting a single result but I can imagine this
>> would be an issue where the REST step actually comes back with multiple
>> items in the array.
>>
>> Any ideas?
>> _______________________________________________
>> cisco-voip mailing list
>> cisco-voip@puck.nether.net
>> https://puck.nether.net/mailman/listinfo/cisco-voip
>>
>
Re: UCCX REST JSON Array Response to String [ In reply to ]
I had this typed up, but then got pulled away. I see now that Tan-the-man
already replied, but I will still hit send anyway.

I use the following jsonpath tester, since it's based on the jaway
implementation, the same as UCCX.

https://jsonpath.herokuapp.com/

[image: image.png]

You can see that the following json path $[0].status works to return
delivered. It also works in UCCX:

[image: image.png]

$ = the entire thing, and since the entire thing is an array, you can just
index it like a normal array in any other language.

PS To use the String http_resp in the Create JSON Document step, I do
this: (Document) http_resp.





On Thu, Jul 30, 2020 at 5:21 PM Brian Meade <bmeade90@vt.edu> wrote:

> Tanner,
>
> It looks like your solution should work. I had tried a couple of
> different ways of trying to get the status from the first Element. I'll
> give that a try with your JSONPath.
>
> Thanks,
> Brian Meade
>
> On Thu, Jul 30, 2020 at 6:17 PM Tanner Ezell <tanner.ezell@gmail.com>
> wrote:
>
>> We need to see how you're converting, and how you're querying to give you
>> meaningful help.
>>
>> Quick 5 second POC using your input string:
>>
>> [image: image.png]
>>
>> On Thu, Jul 30, 2020 at 2:29 PM Brian Meade <bmeade90@vt.edu> wrote:
>>
>>> This is probably something Anthony knows off the top of his head but at
>>> least we'll get his answer archived.
>>>
>>> I've got a UCCX Script doing a REST Call and the response JSON is
>>> actually an array (indicated by the square brackets) even though it's only
>>> one response. The resulting String looks like this:
>>> U"[{\"status\":\"Delivered\"}]"
>>>
>>> Converting this into a Document then JSON Document seems to not work
>>> properly because of this bracket issue. The JSON Document ends up looking
>>> like this:
>>> TEXT[[{\"status\":\"Delivered\"}]]"
>>>
>>> The GET JSON Document Data step then fails to find anything using the
>>> JSONPath.
>>>
>>> To work around it, we used substring to remove the set of square
>>> brackets around the original response string before converting to a Doc
>>> which works and resolves the issue but I'm thinking there's gotta be a
>>> better solution.
>>>
>>> I imagine many JSON responses are probably going to contain arrays. In
>>> this case, we're always getting a single result but I can imagine this
>>> would be an issue where the REST step actually comes back with multiple
>>> items in the array.
>>>
>>> Any ideas?
>>> _______________________________________________
>>> cisco-voip mailing list
>>> cisco-voip@puck.nether.net
>>> https://puck.nether.net/mailman/listinfo/cisco-voip
>>>
>> _______________________________________________
> cisco-voip mailing list
> cisco-voip@puck.nether.net
> https://puck.nether.net/mailman/listinfo/cisco-voip
>
Re: UCCX REST JSON Array Response to String [ In reply to ]
Awesome, thanks for the additional info!

On Thu, Jul 30, 2020 at 6:58 PM Anthony Holloway <
avholloway+cisco-voip@gmail.com> wrote:

> I had this typed up, but then got pulled away. I see now that Tan-the-man
> already replied, but I will still hit send anyway.
>
> I use the following jsonpath tester, since it's based on the jaway
> implementation, the same as UCCX.
>
> https://jsonpath.herokuapp.com/
>
> [image: image.png]
>
> You can see that the following json path $[0].status works to return
> delivered. It also works in UCCX:
>
> [image: image.png]
>
> $ = the entire thing, and since the entire thing is an array, you can just
> index it like a normal array in any other language.
>
> PS To use the String http_resp in the Create JSON Document step, I do
> this: (Document) http_resp.
>
>
>
>
>
> On Thu, Jul 30, 2020 at 5:21 PM Brian Meade <bmeade90@vt.edu> wrote:
>
>> Tanner,
>>
>> It looks like your solution should work. I had tried a couple of
>> different ways of trying to get the status from the first Element. I'll
>> give that a try with your JSONPath.
>>
>> Thanks,
>> Brian Meade
>>
>> On Thu, Jul 30, 2020 at 6:17 PM Tanner Ezell <tanner.ezell@gmail.com>
>> wrote:
>>
>>> We need to see how you're converting, and how you're querying to give
>>> you meaningful help.
>>>
>>> Quick 5 second POC using your input string:
>>>
>>> [image: image.png]
>>>
>>> On Thu, Jul 30, 2020 at 2:29 PM Brian Meade <bmeade90@vt.edu> wrote:
>>>
>>>> This is probably something Anthony knows off the top of his head but at
>>>> least we'll get his answer archived.
>>>>
>>>> I've got a UCCX Script doing a REST Call and the response JSON is
>>>> actually an array (indicated by the square brackets) even though it's only
>>>> one response. The resulting String looks like this:
>>>> U"[{\"status\":\"Delivered\"}]"
>>>>
>>>> Converting this into a Document then JSON Document seems to not work
>>>> properly because of this bracket issue. The JSON Document ends up looking
>>>> like this:
>>>> TEXT[[{\"status\":\"Delivered\"}]]"
>>>>
>>>> The GET JSON Document Data step then fails to find anything using the
>>>> JSONPath.
>>>>
>>>> To work around it, we used substring to remove the set of square
>>>> brackets around the original response string before converting to a Doc
>>>> which works and resolves the issue but I'm thinking there's gotta be a
>>>> better solution.
>>>>
>>>> I imagine many JSON responses are probably going to contain arrays. In
>>>> this case, we're always getting a single result but I can imagine this
>>>> would be an issue where the REST step actually comes back with multiple
>>>> items in the array.
>>>>
>>>> Any ideas?
>>>> _______________________________________________
>>>> cisco-voip mailing list
>>>> cisco-voip@puck.nether.net
>>>> https://puck.nether.net/mailman/listinfo/cisco-voip
>>>>
>>> _______________________________________________
>> cisco-voip mailing list
>> cisco-voip@puck.nether.net
>> https://puck.nether.net/mailman/listinfo/cisco-voip
>>
>
Re: UCCX REST JSON Array Response to String [ In reply to ]
Tanner/Anthony,

I confirmed those JSONPath's worked correctly for the actual production
JSON as well!

Thanks,
Brian Meade

On Fri, Jul 31, 2020 at 11:08 AM Brian Meade <bmeade90@vt.edu> wrote:

> Awesome, thanks for the additional info!
>
> On Thu, Jul 30, 2020 at 6:58 PM Anthony Holloway <
> avholloway+cisco-voip@gmail.com> wrote:
>
>> I had this typed up, but then got pulled away. I see now that
>> Tan-the-man already replied, but I will still hit send anyway.
>>
>> I use the following jsonpath tester, since it's based on the jaway
>> implementation, the same as UCCX.
>>
>> https://jsonpath.herokuapp.com/
>>
>> [image: image.png]
>>
>> You can see that the following json path $[0].status works to return
>> delivered. It also works in UCCX:
>>
>> [image: image.png]
>>
>> $ = the entire thing, and since the entire thing is an array, you can
>> just index it like a normal array in any other language.
>>
>> PS To use the String http_resp in the Create JSON Document step, I do
>> this: (Document) http_resp.
>>
>>
>>
>>
>>
>> On Thu, Jul 30, 2020 at 5:21 PM Brian Meade <bmeade90@vt.edu> wrote:
>>
>>> Tanner,
>>>
>>> It looks like your solution should work. I had tried a couple of
>>> different ways of trying to get the status from the first Element. I'll
>>> give that a try with your JSONPath.
>>>
>>> Thanks,
>>> Brian Meade
>>>
>>> On Thu, Jul 30, 2020 at 6:17 PM Tanner Ezell <tanner.ezell@gmail.com>
>>> wrote:
>>>
>>>> We need to see how you're converting, and how you're querying to give
>>>> you meaningful help.
>>>>
>>>> Quick 5 second POC using your input string:
>>>>
>>>> [image: image.png]
>>>>
>>>> On Thu, Jul 30, 2020 at 2:29 PM Brian Meade <bmeade90@vt.edu> wrote:
>>>>
>>>>> This is probably something Anthony knows off the top of his head but
>>>>> at least we'll get his answer archived.
>>>>>
>>>>> I've got a UCCX Script doing a REST Call and the response JSON is
>>>>> actually an array (indicated by the square brackets) even though it's only
>>>>> one response. The resulting String looks like this:
>>>>> U"[{\"status\":\"Delivered\"}]"
>>>>>
>>>>> Converting this into a Document then JSON Document seems to not work
>>>>> properly because of this bracket issue. The JSON Document ends up looking
>>>>> like this:
>>>>> TEXT[[{\"status\":\"Delivered\"}]]"
>>>>>
>>>>> The GET JSON Document Data step then fails to find anything using the
>>>>> JSONPath.
>>>>>
>>>>> To work around it, we used substring to remove the set of square
>>>>> brackets around the original response string before converting to a Doc
>>>>> which works and resolves the issue but I'm thinking there's gotta be a
>>>>> better solution.
>>>>>
>>>>> I imagine many JSON responses are probably going to contain arrays.
>>>>> In this case, we're always getting a single result but I can imagine this
>>>>> would be an issue where the REST step actually comes back with multiple
>>>>> items in the array.
>>>>>
>>>>> Any ideas?
>>>>> _______________________________________________
>>>>> cisco-voip mailing list
>>>>> cisco-voip@puck.nether.net
>>>>> https://puck.nether.net/mailman/listinfo/cisco-voip
>>>>>
>>>> _______________________________________________
>>> cisco-voip mailing list
>>> cisco-voip@puck.nether.net
>>> https://puck.nether.net/mailman/listinfo/cisco-voip
>>>
>>