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


  • 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

  • Beta Platinum

    @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


  • @bonemap wow..that is perfect. Thanks


  • 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"
  • Beta Platinum

    @agentsimon2 said:

    get this out of the returned string


    JSON-Demo-bonemap.izz

    Best Wishes

    Russell


  • 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

  • Beta Platinum

    @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


  • 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