I
I
Igor Dominator2014-03-26 22:54:31
JavaScript
Igor Dominator, 2014-03-26 22:54:31

How to parse image from Json?

The server sends these lines

{
    "data": {
        "current_condition": [{
            "cloudcover": "75",
            "humidity": "93",
            "observation_time": "06:38 PM",
            "precipMM": "0.6",
            "pressure": "1016",
            "temp_C": "4",
            "temp_F": "39",
            "visibility": "10",
            "weatherCode": "116",
            "weatherDesc": [{
                "value": "Partly Cloudy"
            }],
            "weatherIconUrl": [{
                "value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0004_black_low_cloud.png"
            }],
            "winddir16Point": "NNW",
            "winddirDegree": "340",
            "windspeedKmph": "7",
            "windspeedMiles": "4"
        }],
}

parsim
function LocalWeatherCallback(localWeather) {
    output = "<br/> Изображение: " + localWeather.data.current_condition[0].weatherIconUrl[0].value;
    output += "<br/> Местоположение: " + localWeather.data.request[0].query;
    output += "<br/> Температура по цельсию C: " + localWeather.data.current_condition[0].temp_C;
        output += "<br/> Облачность: " + localWeather.data.current_condition[0].cloudcover;
        output += "<br/> Влажность: " + localWeather.data.current_condition[0].humidity;
        output += "<br/> Видимость: " + localWeather.data.current_condition[0].weatherDesc[0].value;
        output += "<br/> Скорость ветра (км/ч): " + localWeather.data.current_condition[0].windspeedKmph;
        output += "<br/> Давление: " + localWeather.data.current_condition[0].pressure;

        resultContainer.empty();
        resultContainer.html(output);

    }

the result is only the link cdn.worldweatheronline.net/images/wsymbols01_png_6...
and not the image itself. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Morozov, 2014-03-26
@SNPAC

Um, well, you didn’t create a tag.
This
I guess it should look something like this:

output = "<br/> Изображение: <img src='" + localWeather.data.current_condition[0].weatherIconUrl[0].value + "' />";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question