How to parse JSON with ThingHTTP when field names have spaces? Standard dot notation doesn't with ThingHTTP?
조회 수: 6 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Vinod
2021년 10월 7일
편집: Vinod
2021년 10월 7일
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.
Can you tell me more about the application so I may give you appropriate suggestions?
댓글 수: 3
Vinod
2021년 10월 8일
That JSON is particularly hard to build a parse string in the thingHTTP parse string - specifically because of the periods and spaces in the JSON keys. However, you could use the vastly more flexible MATLAB Analysis app on ThingSpeak to get the data, parse and write it to a channel's field, for example:
data = webread('https://wozo9.mocklab.io/json/1')
thingSpeakWrite(<YOUR_CHANNEL_ID>,str2double(data.GlobalQuote.x05_Price),'WriteKey','YourChannelWriteAPIKey')
Then you can read it back using the channel's last.json
커뮤니티
더 많은 답변 보기: ThingSpeak 커뮤니티
참고 항목
카테고리
Help Center 및 File Exchange에서 Read Data from Channel에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!