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
  ELK M1 Client Interface question lleo 1 155 06-12-2019, 08:15 AM
Last Post: Dean Roddey
  Question on Socket Error kblagron 4 487 04-07-2019, 09:19 PM
Last Post: kblagron
  Values Tab - Regular Expression Question bryanb 22 3,129 03-30-2019, 04:07 PM
Last Post: rbroders
  Stupid question: How can I read a motion or other field state change ghurty 10 974 01-10-2019, 10:10 AM
Last Post: Dean Roddey
  Basic CML question lleo 12 1,314 12-14-2018, 06:50 PM
Last Post: Dean Roddey
  Moving MS question IVB 15 1,138 12-08-2018, 10:43 PM
Last Post: IVB
  Auto Generate general question carealtor 4 838 11-12-2018, 09:22 PM
Last Post: carealtor
  Timer Driver Question kblagron 5 1,268 09-14-2018, 02:43 AM
Last Post: znelbok
  Question on Formatting of Variable Text kblagron 2 1,138 09-07-2018, 08:52 PM
Last Post: kblagron
  Basic Debugging Question RichardU 7 2,363 02-21-2018, 09:09 AM
Last Post: RichardU

Forum Jump:


Users browsing this thread: 1 Guest(s)