Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question on Parsing a String in a CML Macro
#1
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.
Reply
#2
My first stab at this was as follows:

                        DataParm.Cut(0,24);
                        DataParm.Split(TmpStr,''',False);

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  SSL Certificate Question gReatAutomation 1 627 10-26-2020, 07:48 AM
Last Post: gReatAutomation
  V2 Question - OpenWeatherMap Using their New JSON Data Feed kblagron 7 1,572 05-07-2020, 01:40 PM
Last Post: Dean Roddey
  SendWOL from Macro dlmorgan999 4 1,673 04-25-2020, 08:12 AM
Last Post: dlmorgan999
  Dynamic Overlay Question bryanb 4 904 04-17-2020, 03:48 AM
Last Post: bryanb
  Triggered Event on Timer Question znelbok 7 2,651 12-09-2019, 02:10 PM
Last Post: znelbok
  Question on CQC Driver Pack Install kblagron 1 955 11-26-2019, 06:38 PM
Last Post: Dean Roddey
  SONOS Driver Question gReatAutomation 13 4,147 08-23-2019, 12:37 PM
Last Post: Dean Roddey
  Insteon V2 Driver Question kblagron 1 927 08-01-2019, 10:51 AM
Last Post: kblagron
  ELK M1 Client Interface question lleo 1 1,051 06-12-2019, 08:15 AM
Last Post: Dean Roddey
  Question on Socket Error kblagron 4 1,898 04-07-2019, 09:19 PM
Last Post: kblagron

Forum Jump:


Users browsing this thread: 1 Guest(s)