JSON parsing

Avatar
  • updated

I created a TcpServer with a JSON parser:

Image 4625

I added a string parser with a token :

Image 4627


I use Postman and send :

{"TestData":{"Data1":"1"}}


ComfortClick receives data:

POST / HTTP/1.1

Content-Type: text/plain

User-Agent: PostmanRuntime/7.32.3

Accept: */*

Postman-Token: e79d7b2e-8a0a-4ef6-bd47-8d5cc7e8c6f3

Host: 192.168.1.7:16900

Accept-Encoding: gzip, deflate, br

Connection: keep-alive

Content-Length: 26


{"TestData":{"Data1":"1"}}


But the parser throws an error:

Devices : 15.08.2023 14:54:09 : Error : Devices\Test\String : Error parsing received data. Unexpected character encountered while parsing value: P. Path , line 0, position 0. w Newtonsoft.Json.JsonTextReader.ParseValue()

w Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)

w Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)

w ComfortClick.Tasks.Common.ReceiverBase.OnDataReceived(String data)


It looks like the header is being passed to the parser, not the JSON itself.

Bug or my configuration error?

How to disable header passing to parser?

Tested on ComfortClick v 4.9.36

Avatar
Jürgen Jürgenson
Quote from Krzysztof Szczepański

Image 4628


not working :( same error.

Devices : 15.08.2023 16:37:59 : Error : Devices\Test\String : Error parsing received data. Unexpected character encountered while parsing value: P. Path , line 0, position 0. w Newtonsoft.Json.JsonTextReader.ParseValue()

Have you tried different parser encodings too? Set it to none.

Avatar

Image 4628


not working :( same error.

Devices : 15.08.2023 16:37:59 : Error : Devices\Test\String : Error parsing received data. Unexpected character encountered while parsing value: P. Path , line 0, position 0. w Newtonsoft.Json.JsonTextReader.ParseValue()

Avatar
Jürgen Jürgenson

Hey

Try if: .TestData.Data1 works. Note the dot in front.