Is it possible to get multiple values in single Oraclize query?

contract CheckBet is usingOraclize {

struct Weather {
    uint curr_temperature;
    uint high_temperature;
    uint low_temperature;
Weather weather;

/// Event for debugging
event Log(string text);

function CheckBet() {

function get_weather_status() payable{
    Log("Oraclize query was sent, waiting for the answer.."); 

//callback function for Oraclize
function __callback(bytes32 _myid, string _result) {
    require (msg.sender == oraclize_cbAddress());
    weather.low_temperature = parseInt(_result); 

In function get_weather_status, I'm getting min. temp. I want temp_max, curr_temp too.

Is it possible in single Oraclize query?


  "main": {

3 Answers 3


You should be able do this using JSONPATH.

(oraclize_query("URL","json(http://samples.openweathermap.org/data/2.5/weather?q=Lond`on,uk&appid=b6907d289e10d714a6e88b30761fae22).main[temp, temp_min, temp_max]"));

You can examine the results here http://app.oraclize.it/home/test_query#VVJMKEdFVCk=:anNvbihodHRwOi8vc2FtcGxlcy5vcGVud2VhdGhlcm1hcC5vcmcvZGF0YS8yLjUvd2VhdGhlcj9xPUxvbmRgb24sdWsmYXBwaWQ9YjY5MDdkMjg5ZTEwZDcxNGE2ZTg4YjMwNzYxZmFlMjIpLm1haW5bdGVtcCwgdGVtcF9taW4sIHRlbXBfbWF4XQ==


Quick googling says it might not be trivial. Have a look at https://github.com/oraclize/ethereum-examples/issues/10 So, you'd have to parse the result yourself.

P.S. Please accept the answers to your previous questions if you are satisfied with them.


For the query: "json(http://samples.openweathermap.org/data/2.5/weather?q=Lond`on,uk&appid=b6907d289e10d714a6e88b30761fae22).main[temp, pressure, humidity, temp_min, temp_max]"

Follow these rules: https://github.com/json-path/JsonPath

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.