• Isadora
  • Get it
  • Forum
  • Help
  • ADD-ONS
  • Newsletter
  • Impressum
  • Dsgvo
  • Impressum
Forum
    • Categories
    • Recent
    • Popular
    • Tags
    • Register
    • Login

    [ANSWERED] Parsing a text string with TCP In Watcher - Text

    Interfacing
    2
    8
    801
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • agentsimon2A
      agentsimon2
      last edited by Woland

      Re: [TCP Actors & REST Interface to Database (Neo4j)](/topic/751/tcp-actors-rest-interface-to-database-neo4j)

      I am receiving a text string 

      {"status":"success","data":{"city":"Da Nang","state":"Da Nang","country":"Vietnam","location":{"type":"Point","coordinates":[108.207097,16.048587]},"current":{"weather":{"ts":"2020-04-05T06:00:00.000Z","tp":31,"pr":1014,"hu":58,"ws":3.1,"wd":110,"ic":"02d"},"pollution":{"ts":"2020-04-05T06:00:00.000Z","aqius":38,"mainus":"p2","aqicn":13,"maincn":"p2"}}}}
      and wish to parse to down to the number after "aqius":
      

      My attempt is not working! I am using msg:string={00-FF} which gets the full string but when I use msg : string = [aqius":] "," output:string={00-FF} I get nothing printed from the msg outout of the TCP In Watcher-Text
      Simon

      Running: MBP 13 2019 1 .4 GHz Quad-Core Intel Core i5 8 GB 2133 MHz | Catalina 10.15.4 | located in Da Nang, Vietnam.
      Github https://github.com/agentsimon

      bonemapB 1 Reply Last reply Reply Quote 0
      • bonemapB
        bonemap Izzy Guru @agentsimon2
        last edited by

        @agentsimon2 said:

        I am receiving a text string 

         You will be able to use the parsing module made available a couple of weeks ago here:

        https://community.troikatronix.com/topic/6503/json-parser-actor-for-macos-and-windows-public-beta

        Kind Regards

        Russell

        http://bonemap.com | Australia
        Izzy STD/USB 3.2.6 | + Beta 3.x.x
        MBP 16” 2019 2.4 GHz Intel i9 64GB AMD Radeon Pro 5500 8 GB 4TB SSD | 14.1.2 Sonoma
        Mac Studio 2023 M2 Ultra 128GB | OSX 14.1.2 Sonoma
        A range of deployable older Macs

        agentsimon2A 1 Reply Last reply Reply Quote 1
        • agentsimon2A
          agentsimon2 @bonemap
          last edited by

          @bonemap wow..that is perfect. Thanks

          Running: MBP 13 2019 1 .4 GHz Quad-Core Intel Core i5 8 GB 2133 MHz | Catalina 10.15.4 | located in Da Nang, Vietnam.
          Github https://github.com/agentsimon

          1 Reply Last reply Reply Quote 2
          • agentsimon2A
            agentsimon2
            last edited by

            ohh so I have been trying to parse something from thingsspeak.com and it returns this

            {"channel":{"id":1035630,"name":"RSSI","description":"RSSI value","latitude":"0.0","longitude":"0.0","field1":"rssi","created_at":"2020-04-11T09:56:53Z","updated_at":"2020-04-11T10:27:34Z","last_entry_id":31},
            "feeds":[{"created_at":"2020-04-11T11:37:00Z","entry_id":30,"field1":"-36"},{"created_at":"2020-04-11T11:51:04Z","entry_id":31,"field1":"-42"}]}
            

            How do I get this out of the returned string? It's in some square brackets and I just can not work out how to do it!

            "field1":"-42"

            Running: MBP 13 2019 1 .4 GHz Quad-Core Intel Core i5 8 GB 2133 MHz | Catalina 10.15.4 | located in Da Nang, Vietnam.
            Github https://github.com/agentsimon

            1 Reply Last reply Reply Quote 0
            • bonemapB
              bonemap Izzy Guru
              last edited by bonemap

              @agentsimon2 said:

              get this out of the returned string


              JSON-Demo-bonemap.izz

              Best Wishes

              Russell

              http://bonemap.com | Australia
              Izzy STD/USB 3.2.6 | + Beta 3.x.x
              MBP 16” 2019 2.4 GHz Intel i9 64GB AMD Radeon Pro 5500 8 GB 4TB SSD | 14.1.2 Sonoma
              Mac Studio 2023 M2 Ultra 128GB | OSX 14.1.2 Sonoma
              A range of deployable older Macs

              1 Reply Last reply Reply Quote 0
              • agentsimon2A
                agentsimon2
                last edited by

                ok but when I add the Get Text to the json in on the first parser it fails.. I got round it by adding a text chopper.

                rssi.izz

                PS I'll delete the API key later

                Running: MBP 13 2019 1 .4 GHz Quad-Core Intel Core i5 8 GB 2133 MHz | Catalina 10.15.4 | located in Da Nang, Vietnam.
                Github https://github.com/agentsimon

                bonemapB 1 Reply Last reply Reply Quote 1
                • bonemapB
                  bonemap Izzy Guru @agentsimon2
                  last edited by bonemap

                  @agentsimon2

                  I had a second look at your patch. It actually works! We just have to remember that arrays in javascript start at '0' -


                  GetURL with Array.izz

                  best wishes Russell

                  http://bonemap.com | Australia
                  Izzy STD/USB 3.2.6 | + Beta 3.x.x
                  MBP 16” 2019 2.4 GHz Intel i9 64GB AMD Radeon Pro 5500 8 GB 4TB SSD | 14.1.2 Sonoma
                  Mac Studio 2023 M2 Ultra 128GB | OSX 14.1.2 Sonoma
                  A range of deployable older Macs

                  1 Reply Last reply Reply Quote 0
                  • agentsimon2A
                    agentsimon2
                    last edited by

                    ahh I didn't know that...so it's an array whose first element is referenced as 0. I see that the number of elements returned by the URL can be changed so it's possible to collect, say the last 10 values posted to Thingsspeak. Now I can do some statistics on the data, calculate highest/lowest, the mean, rate of change...interesting..the stats could be used to trigger events in a performance.

                    thanks again Simon

                    Running: MBP 13 2019 1 .4 GHz Quad-Core Intel Core i5 8 GB 2133 MHz | Catalina 10.15.4 | located in Da Nang, Vietnam.
                    Github https://github.com/agentsimon

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post