JSON

Solution in Python with Requests

This article solves the following challenge: 

GET request from a REST-Service

To get and save the JSON data in Python there are many libraries we could use, I'm showing you how to do it with one of the more common ones "Requests". It works as follows:
import requests
jsondata = requests.get("http://exampleurl.com/get").json()
These two lines are actually a fully working python program which extracts the data on the example URL via "get()" and forms it into a json via "json()". The result gets saved into the "jsondata" variable.

Evaluate complexity of present statement:

Select ratingCancelGuessingPassing knowledgeKnowledgeableExpert

Your rating: None Average: 2 (1 vote)

Taggings:

How to convert XML to JSON by using JavaScript or Java?

<p>&nbsp;</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;">Over the last years the simple data format JSON had a great inpetus in the service-oriented architecture and especially in the area of internet services. It is widely used because of its compactness and easy understandability.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px;">&nbsp;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;">JSON is lightweight and was used for several of my projects. However, the convertion by hand (Or by an own routine) is an unacceptable quality problem.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px;">&nbsp;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;">A transformation could look like the this example:</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px;">&nbsp;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;">The&nbsp;<strong>XML </strong>of image xml.png&nbsp;<span style="font-family: 'Trebuchet MS', sans-serif; font-size: 13px;">should be transformed to the&nbsp;<strong>JSON</strong> representation of image json.png.</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px 'Trebuchet MS'; min-height: 15.0px;">So to a simple representation using curly braces.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 21.0px; font: 13.0px 'Trebuchet MS';"><span style="font-family: Helvetica, sans-serif; font-size: small;"><span style="font-size: 12px;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: small;"><span style="font-size: 13px;"><br /></span></span></span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 21.0px; font: 12.0px Helvetica;">JavaScript could be used to convert the data before it is passed on to the Java application. The conversion could also be done in Java itself.</p><p>&nbsp;</p>
Subscribe to JSON