Official website

Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Thursday, March 5, 2015

Extracting data from JSON and XML

Web API connector is released and supports both JSON and XML response parsing. This feature opens up the possibility of connecting to a huge range of potential APIs and therefore reducing the cost for additional equipment. For example, if you want to create some tasks based on weather conditions, you can achieve that without a weather station, but by gathering information from the cloud.

In addition to this post let's do some JSON examples from Yahoo Weather API. I will also use the Code Beautify online code editor for a good human-readable representation of the response.

Step 1: Copy and Paste the endpoint URI from yahoo developer website and paste it to the editor.



Step 2: Go to Control Panel->Instructions->Add New Web Service. Address the node you want to retrieve and fill the form items (Name, Endpoint, Node Path). Notice that if the response have a tree structure, you should point the position index of your target in Node Path as seen below. By default will get the first element [index: 0].


By default some editors starts the tree viewer with root/array and then with the absolute tree structure. So, at the "Node Path" field of Jubito, ignore the above of starting path.

Step 3: Go to terminal tab and debug the new Instruction Set. If you get the value then everything went well.


Step 4: Now, let's make an interface and a scenario. Again from Control Panel->Instructions->Add New Instruction Set. Unfold the Add Action(s) and Add to Dashboard and follow the screenshot.


Save and return. Now you're able to make a call from the Dashboard screen.


Step 5: Some other things you can do, is to make a schedule to evaluate the weather and send an email notification when a specified weather acknowledgement applies. Let's take a look to the Evaluator. Once again Control Panel->Instructions->Add New Evaluator. Select the yahoo-test Instruction Set and add some additional text if you wish. As I always remind, the asterisk in front of the Instruction Set is the reflector of a value.


'Then' condition corresponds to another Instruction Set that is responsible to send mail. You can search this blog with 'send mail' keyword to see how to make one.

Step 6: Finally there all set to create the Schedule. Go to Control Panel->Scheduler->Add New. Type a name, repeat, interval at your choice (3600000ms is one hour) and select the Evaluator's Instruction Set.


This schedule will run every hour and evaluate the condition.

All of the above steps are described as a proof of concept. The use-cases may vary depending your needs.

The same logic applies also to XML. You can be advised by this post. If you find any difficulties or discover a bug, please do not hesitate to drop me a message.

Changes applied to jaNET Framework 0.2.6.555+. To check version go to terminal tab and type %about%.

Thursday, November 27, 2014

Web of Things and what's new on the upcoming version

In our days, there is a trend to talk about the Internet of Things, Machine to Machine, Web of Things, etc. However all of the above are considered an integral part of the IoT. I won't discuss any of them in detail, since there are too many articles over the internet.

A vast amount of information, is distributed via web services. Web services are an efficient way of communication, that support interoperable machine-to-machine interaction, over a network. As a developer, I need my platform to be able to consume all these services and produce innovative use-cases.

In this post I would like to share some of the latest developments, that would be available in the next version of Jubito. I'm talking about tailor made methods for native XML and JSON deserialization from web service/web API responses.

Some first tests using Yahoo Weather API.

XML:


JSON:


The current release, based on 0.2.5 jaNET Framework comes with full partial support [ Still under development ]. To check the version, go to Terminal tab and type %about%.