Sneak Peek - Tasker Native Easy JSON Reading
🕑 Added 2021-02-05 18:39:16 +0000 UTCThe other day I had this idea that it could be fairly (if not totally) compatible to add easy JSON reading to Tasker and today I tried it out! :)
In this version of Tasker, if you have a local variable with some JSON data in it you can easily read it with the dot notation!
For example:
- %person has the value {"name":"João", "location":"Portugal"}
- You can read the name by accessing %person.name
- You can read the location by accessing %person.location
It even works for multiple values (arrays)! Let's say you have
- %people has the value [{"name":"João", "location":"Portugal"},{"name":"Janeca", "location":"England"}]
- You can read all the names by accessing %data.name()
- You can read all the locations by accessing %data.location()
You can use all the normal array operations like %data.name(#) to count the number of names, %data.name(<) to get the last name, etc.
Check out this example Task that will give you the current temperature. Super easy to do now! 😁
I'm aware that this has some limitations right now like for example, what if a JSON field has a Tasker incompatible name? I'll try and see what I can do about it :) Maybe have a separate JSON Read action for those special cases?
In any case, you can try out this new feature with the version below. Enjoy and let me know what you think! 😊
https://drive.google.com/file/d/1SvQFvAxFwCk-hArfO_6wOH0UlvvMGi0z/view?usp=sharing
Comments
João Dias
In the JSON there's a "connected" variable that'll tell if you the network is the one that's connected :)
Matt DeKok
Unfortunately, I don't think that will work, because AutoTools gives all nearby networks, but doesn't provide specifically the details of the connected network. Unless I'm missing something...
João Dias
I can't change existing variables because it would break existing setups but you can use the AutoTools Connectivity action to get wifi info in json actually :) I can add something similar to Tasker in the future though!
Matt DeKok
Can existing native variables like %WIFII be converted to JSON? Currently %WIFII looks like: >>> STATE <<< "network name" mac: ip: etc It would be nice to be able to use %WIFII.status or %WIFII.networkName
João Dias
You read my mind 😁 Over the weekend I thought that would be a good solution for more complex cases as well!
João Dias
Yeah. It's a very common use case specially for Web APIs so I think it's an important feature to have 😊
Bernard Tan
Holy shit this is awesome!! Will this eventually support bracket notation as well?
Jay
Intriguing...
Gavin Johnston
This would be a very welcome feature for me! Anything that simplifies the Json process is a good thing 😄
João Dias
Thanks! 😁
Zachary H Denny
Badass!