简体   繁体   中英

Convert byte array from PLC to JSON or Java Object

Is there a way to get a json or Java object out of an byte stream?

If the structure in the plc looks like that

Data
  - id       int
  - pos      array[0..3] of int
  - time     dint

id=5
pos[0]=1
pos[1]=2
pos[2]=3
pos[3]=4
time = 5

I would get a bytearray of [0,5,0,1,0,2,0,3,0,4,0,0,0,5]

Now I want a Json out of this like

{
  id:5,
  pos:[1,2,3,4],
  time:5
}

The Deserialization Process needs to know the Datatypes and the Array lengths . Is there any framework which supports things like that?

JSON 只是文本,因此您可以将 JSON 对象转换为字符串,传输该字符串,然后将其转换回您正在使用的任何 JSON 库数据结构。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM