0

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?

user2071938
  • 2,055
  • 6
  • 28
  • 60

1 Answers1

0

JSON is just text, so you would convert the JSON object to a string, transfer that string, and then convert it back into whatever JSON library data structure you are using.

Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118