Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question on Parsing a String in a CML Macro
I am playing with the Native Echo Smarthome Skill, and had a question on the best way to do this.

I have the following text string:  "{'channel': {'number': '100'}, 'channelMetadata': {}}"

I want to save the number shown (100) into a variable and discard the rest.  What would be the best recommended way to do so in a CML Macro?  I know I can do some splits, strips, and indexes and get to it in 4  or 5 commands, but was curious is there an easier way to capture that?  The Starting point will always be the same, but the number could be 1, 2, or 3 digits long.
My first stab at this was as follows:


I guess that should suffice, but open for other ideas.
That's just JSON, so use the JSON parser and it'll do all of that for you.
Dean Roddey
Explorans limites defectum

Possibly Related Threads…
Thread Author Replies Views Last Post
  SSL Certificate Question gReatAutomation 1 950 10-26-2020, 07:48 AM
Last Post: gReatAutomation
  V2 Question - OpenWeatherMap Using their New JSON Data Feed kblagron 7 2,135 05-07-2020, 01:40 PM
Last Post: Dean Roddey
  SendWOL from Macro dlmorgan999 4 2,077 04-25-2020, 08:12 AM
Last Post: dlmorgan999
  Dynamic Overlay Question bryanb 4 1,370 04-17-2020, 03:48 AM
Last Post: bryanb
  Triggered Event on Timer Question znelbok 7 3,413 12-09-2019, 02:10 PM
Last Post: znelbok
  Question on CQC Driver Pack Install kblagron 1 1,305 11-26-2019, 06:38 PM
Last Post: Dean Roddey
  SONOS Driver Question gReatAutomation 13 5,684 08-23-2019, 12:37 PM
Last Post: Dean Roddey
  Insteon V2 Driver Question kblagron 1 1,276 08-01-2019, 10:51 AM
Last Post: kblagron
  ELK M1 Client Interface question lleo 1 1,334 06-12-2019, 08:15 AM
Last Post: Dean Roddey
  Question on Socket Error kblagron 4 2,262 04-07-2019, 09:19 PM
Last Post: kblagron

Forum Jump:

Users browsing this thread: 1 Guest(s)