How to send JSON - data with nested objects?


#1

Hi,

I try to send data via TCP API with nested objects, but can’t access them within a rule.

Example:

echo ‘{“k”: “key_here”,“d”: {“data1”: “1”, “data2” : “2” }, “t”: “TOPIC1”}’ | nc -i1 cloudsocket.hologram.io 9999

ist accepted by API.

But I can*t access data in rule with <<decdata.data1>>.
RAW-view is showing that data was’nt encoded
"data": “{\“data1\”: \“1\”, \“data2\”: \“2\”}”

result_data":"Error decoding data for variable ‘decdata.data1’

What’s wrong?

Kind regards

Kai


#2

Hmm can you try sending data as a json-encoded string like:
"d":"{\"data1\":\"1\"}"


#3

Works!!!

echo ‘{“k”: “key_here”,“d”: “{“data1”: “1”,“data2”: “1”}”, “t”: “TOPIC1”}’ | nc -i1 cloudsocket.hologram.io 9999

Thank you

Kai


#4

Ok cool, glad that’s working. We’re going to add better nested json support in there in the future