How to parse JSON with ThingHTTP when field names have spaces? Standard dot notation doesn't with ThingHTTP?

9 views (last 30 days)
Boyan Biandov
Boyan Biandov on 6 Oct 2021
Edited: Boyan Biandov on 10 Oct 2021
Hi everyone,
I'm stuck with a challenge how to parse JSON with ThingHTTP when fields have spaces? Standard dot notation doesn't with ThingHTTP - by "standard" I mean I've tried what I've found in terms of syntax on dotted notation with spaces but none have worked.
I'm specifically asking on how to enter the "Parse String" parameters when parsing JSON when fields have spaces in them using the dotted notation. Screen show below. Thank you

Answers (1)

Vinod
Vinod on 7 Oct 2021
Edited: Vinod on 7 Oct 2021
You can parse JSON using the dot notation. Here's an example:
Of course, this is a bit contrived to create a thingHTTP to read from ThingSpeak API, but, since I don't know the URL you are trying to get the data from, I cannot give you a more targeted example.
You can also use WEBREAD in MATLAB and use JSONDECODE on the string.
Can you tell me more about the application so I may give you appropriate suggestions?
  3 Comments
Boyan Biandov
Boyan Biandov on 10 Oct 2021
@Vinod Thank you, I did think of that but then ThingHTTP in itself can not trigger the MATLAB Analysis app in itself so I will have to trigger it with a timer function, so it will keep triggering and populating the channel whether or not my ThingHTTP receives any hits and therefore needs the data which is stored in the channel.
Sort of "plummer's delight" situation with so many pieces in play but complexity aside - the optimization piece is less than optimal, I will be piping data into the channel that may or may not be needed for a long time and I can not predict when ThingHTTP would fire so it's a play between two asynchronous tasks.

Sign in to comment.

Communities

More Answers in the  ThingSpeak Community

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!