ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Wiebe <glenn.wi...@gridgain.com>
Subject Re: Ignite 2.7 REST API returning escape characters
Date Mon, 21 Jan 2019 18:10:07 GMT
On the topic of the actual return, if you look at the documentation, I
believe the Cache Get returns a single level JSON structure that includes a
simple string "existing value" as below:

Get and put
<https://apacheignite.readme.io/docs/rest-api#section-get-and-put>

Get and put command stores the given key-value pair in cache and
returns an existing
value if one existed.
Which as you can see from your response (which I have "prettified"):
{
  "successStatus": 0,
  "affinityNodeId": "8b13ac15-f503-4f4a-ab1f-a7fc3ce93596",
  "sessionToken": null,
  "error": null,
  "response": "{\"name\":\"Ceasar\"}"
}

Which is "proper" if you understand that the "response" object is a simple
string value. In order to preserve the embedded features of the string
(i.e. a string that looks like JSON), the surrounding json document has to
be escaped such that elements of the string that might change the schema of
the object.

In other words, this looks right to me, even if that is not your desired
result. You will need to take this string response and parse it as a JSON
object.

Regards,
  Glenn

On Mon, Jan 21, 2019 at 12:48 PM Ilya Kasnacheev <ilya.kasnacheev@gmail.com>
wrote:
>
> Hello again!
>
> You will also have to supply an interceptor to do this transformation.
Ignite doesn't have native support for JSON so this step is necessary.
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> пн, 21 янв. 2019 г. в 20:22, Ilya Kasnacheev <ilya.kasnacheev@gmail.com>:
>>
>> Hello!
>>
>> I guess this means you store JSON as String in cache. Is this the case?
>>
>> If you want data to be output as JSON you will have to store it
structured (such as with POJOs or Binary Objects).
>>
>> Regards,
>> --
>> Ilya Kasnacheev
>>
>>
>> пн, 21 янв. 2019 г. в 19:47, EMCox <ericcox@outlook.com>:
>>>
>>> Add request:
>>> Date →Mon, 21 Jan 2019 16:40:09 GMT
>>> Content-Type →application/json;charset=utf-8
>>> Content-Length →124
>>> Server →Jetty(9.4.11.v20180605)
>>> POST
>>> http://abcdef00009d15:8080/ignite?cmd=add&key=107&val={
"name":"Ceasar"}&cacheName=default&destId=8b13ac15-f503-4f4a-ab1f-a7fc3ce93596
>>>
{"successStatus":0,"affinityNodeId":"8b13ac15-f503-4f4a-ab1f-a7fc3ce93596","sessionToken":null,"error":null,"response":true}
>>>
>>> Get response:
>>> Date →Mon, 21 Jan 2019 16:41:09 GMT
>>> Content-Type →application/json;charset=utf-8
>>> Content-Length →143
>>> Server →Jetty(9.4.11.v20180605)
>>>
http://abcdef00009d15:8080/ignite?cmd=get&key=107&cacheName=default&destId=8b13ac15-f503-4f4a-ab1f-a7fc3ce93596
>>>
{"successStatus":0,"affinityNodeId":"8b13ac15-f503-4f4a-ab1f-a7fc3ce93596","sessionToken":null,"error":null,"response":"{\"name\":\"Ceasar\"}"}
>>>
>>> Status 200 is returned for both
>>>
>>>
>>>
>>>
>>> --
>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Mime
View raw message