New posts are disabled while we improve the user experience.

You can browse the site, or for urgent issues, raise a query at MyAccount.

question

Upvotes
39 0 4 10

How do I extract just a few values ​​from json data in RTO cloud webscoket?

Hi,

I am receiving data via WebSocket for RTO v2, and the data comes in the format shown in the attached file. I cannot find out how to assign this data to a variable. I only see it written in the run area. The data is written after the following line of code, but I am unsure how to handle this JSON object on the Java side.


_websocket.sendText(requestJsonString);


In my previously written code, I was able to receive it using fieldlist, but I don't know how to retrieve it in RTO v2.


@Override
public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent ommConsumerEvent) {
    arylNewVirbaseRateRics = decodeFieldList(refreshMsg.payload().fieldList());
}


I have one more question. Do I have to use websocket for cloud RTOv2? Can't I get data via http like before? After all, this code will only run at certain times of the day, it doesn't need to be running all the time.


Thanks. RTOv2.txt

#technologywebsocketsjavarrto
rtov2.txt (3.1 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
25.1k 68 15 21

Hello @SelcukYAPICI,

The data content and the extraction mechanism is exactly the same in RTO. Only thing which has changed from v1 to v2 is the means to authenticate with the system. Everything related to websocket part of programming is exactly the same - and the code that you had previously will also work with v2 authentication.

For an example of how to extract the JSON fields in Java, please see these examples in the GitHub.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.