Hello,
This is my first time using json in android, the json is getting downloaded,
i'm just getting an parse error
I understand the concept of json's arrays, objects, keys & values
I added a JSON example below
This is my parsing code :
I uploaded a JSON example on :
http://m.uploadedit.com/bbtc/1512045722310.txt
(because of the post limit)
Would love to know what my mistake, been looking at it for a while now
This is my first time using json in android, the json is getting downloaded,
i'm just getting an parse error
I understand the concept of json's arrays, objects, keys & values
I added a JSON example below
This is my parsing code :
Code:
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
JSONArray getAccuweather = jsonObj.getJSONArray("weather");
// looping through All Contacts
for (int i = 0; i < getAccuweather.length(); i++) {
JSONObject getInfo = getAccuweather.getJSONObject(i);
String DateTimeArray = getInfo.getString("DateTime");
String EpochDateTimeArray = getInfo.getString("EpochDateTime");
String WeatherIconArray = getInfo.getString("WeatherIcon");
String IconPhraseArray = getInfo.getString("IconPhrase");
String IsDaylighteArray = getInfo.getString("IsDaylight");
String TemperatureeArray = getInfo.getString("Temperature");
String RealFeelTemperatureArray = getInfo.getString("RealFeelTemperature");
String WetBulbTemperatureArray = getInfo.getString("WetBulbTemperature");
String DewPointArray = getInfo.getString("DewPoint");
String WindArray = getInfo.getString("Wind");
String DirectionArray = getInfo.getString("Direction");
String WindGustArray = getInfo.getString("WindGust");
String RelativeHumidityArray = getInfo.getString("RelativeHumidity");
String CeilingArray = getInfo.getString("Ceiling");
String UVIndexArray = getInfo.getString("UVIndex");
String UVIndexTextArray = getInfo.getString("UVIndexText");
String PrecipitationProbabilityArray = getInfo.getString("PrecipitationProbability");
String RainProbabilityArray = getInfo.getString("RainProbability");
String SnowProbabilityArray = getInfo.getString("SnowProbability");
String IceProbabilityArray = getInfo.getString("IceProbability");
String TotalLiquidArray = getInfo.getString("TotalLiquid");
String RainArray = getInfo.getString("Rain");
String SnowArray = getInfo.getString("Snow");
String IceArray = getInfo.getString("Ice");
String CloudCoverArray = getInfo.getString("CloudCover");
String MobileLinkArray = getInfo.getString("MobileLink");
String Link = getInfo.getString("Link");
// JSON Object (Date & Time Object)
JSONObject DateTimeObject = getInfo.getJSONObject("DateTime");
String DateTime = DateTimeObject.getString("DateTime");
// JSON Object (EpochDateTimeO bject)
JSONObject EpochDateObject = getInfo.getJSONObject("EpochDateTime");
int EpochDate = EpochDateObject.getInt("EpochDateTime");
// JSON Object (WeatherIcon Object)
JSONObject WeatherIconObject = getInfo.getJSONObject("WeatherIcon");
int WeatherIcon = WeatherIconObject.getInt("WeatherIcon");
// JSON Object (IconPhrase Object)
JSONObject IconPhraseObject = getInfo.getJSONObject("IconPhrase");
String IconPhrase = IconPhraseObject.getString("IconPhrase");
// JSON Object (IsDaylight Object)
JSONObject IsDaylightObject = getInfo.getJSONObject("IsDaylight");
boolean IsDaylight = IsDaylightObject.getBoolean("IsDaylight");
// JSON Object (Temperature Object)
JSONObject DateTimeObject_Temperature = DateTimeObject.getJSONObject("Temperature");
int DateTimeValue = DateTimeObject_Temperature.getInt("Value");
String Unit = DateTimeObject_Temperature.getString("Unit");
int UnitType = DateTimeObject_Temperature.getInt("UnitType");
// JSON Object (RealFeelTemperature Object)
JSONObject RealFeelTemperatureObject = getInfo.getJSONObject("RealFeelTemperature");
int RealFeelTemperatureValue = RealFeelTemperatureObject.getInt("Value");
String RealFeelTemperatureUnit = RealFeelTemperatureObject.getString("Unit");
int RealFeelTemperatureUnitType = RealFeelTemperatureObject.getInt("UnitType");
// JSON Object (WetBulbTemperature Object)
JSONObject WetBulbTemperatureObject = getInfo.getJSONObject("WetBulbTemperature");
int WetBulbTemperatureValue = WetBulbTemperatureObject.getInt("Value");
String WetBulbTemperatureeUnit = WetBulbTemperatureObject.getString("Unit");
int WetBulbTemperatureType = WetBulbTemperatureObject.getInt("UnitType");
// JSON Object (DewPoint Object)
JSONObject DewPointObject = getInfo.getJSONObject("DewPoint");
int DewPointValue = DewPointObject.getInt("Value");
String DewPointUnit = DewPointObject.getString("Unit");
int DewPointUnitType = DewPointObject.getInt("UnitType");
// JSON Object (Wind Object)
JSONObject WindObject = getInfo.getJSONObject("Wind");
JSONObject WindObject_Wind = WindObject.getJSONObject("Speed");
int WindValue = WindObject_Wind.getInt("Value");
String WindUnit = WindObject_Wind.getString("Unit");
int WindUnitType = WindObject_Wind.getInt("UnitType");
JSONObject WindObject_Direction = getInfo.getJSONObject("Direction");
int Wind_Direction_Degrees = WindObject_Direction.getInt("Degrees");
String Wind_Direction_Localized = WindObject_Direction.getString("Localized");
String Wind_Direction_English = WindObject_Direction.getString("English");
// JSON Object (WindGust Object)
JSONObject WindGustObject = getInfo.getJSONObject("WindGust");
JSONObject WindGustObject_WindGuest = WindGustObject.getJSONObject("Speed");
int WindGuestValue = WindGustObject_WindGuest.getInt("Value");
String WindGuestUnit = WindGustObject_WindGuest.getString("Unit");
int WindGuestUnitType = WindGustObject_WindGuest.getInt("UnitType");
// JSON Object (RelativeHumidity Object)
JSONObject RelativeHumidityObject = getInfo.getJSONObject("RelativeHumidity");
int RelativeHumidityUnit = RelativeHumidityObject.getInt("RelativeHumidity");
JSONObject VisibilityObject = RelativeHumidityObject.getJSONObject("Visibility");
int Visibiliyt_value = VisibilityObject.getInt("Value");
String Visibility_Unit = VisibilityObject.getString("Unit");
int Visibility_UnitType = VisibilityObject.getInt("UnitType");
// JSON Object (Ceiling Object)
JSONObject CeilingObject = getInfo.getJSONObject("Visibility");
int Ceiling_value = CeilingObject.getInt("Value");
String Ceiling_Unit = CeilingObject.getString("Unit");
int Ceiling_UnitType = CeilingObject.getInt("UnitType");
// JSON Object (UVIndex Object)
JSONObject UVIndexObject = getInfo.getJSONObject("UVIndex");
String UVIndex = UVIndexObject.getString("UVIndex");
// JSON Object (PrecipitationProbability Object)
JSONObject PrecipitationProbabilityObject = getInfo.getJSONObject("PrecipitationProbability");
int PrecipitationProbability = PrecipitationProbabilityObject.getInt("PrecipitationProbability");
// JSON Object (UVIndexText Object)
JSONObject UVIndexTextObject = getInfo.getJSONObject("UVIndexText");
int UVIndexText = UVIndexTextObject.getInt("UVIndexText");
// JSON Object (SnowProbability Object)
JSONObject SnowProbabilityObject = getInfo.getJSONObject("SnowProbability");
int SnowProbability = SnowProbabilityObject.getInt("SnowProbability");
// JSON Object (IceProbability Object)
JSONObject IceProbabilityObject = getInfo.getJSONObject("IceProbability");
int IceProbability = IceProbabilityObject.getInt("IceProbability");
// JSON Object (TotalLiquid Object)
JSONObject TotalLiquidObject = getInfo.getJSONObject("TotalLiquid");
int TotalLiquidValue = TotalLiquidObject.getInt("Value");
String TotalLiquidUnit = TotalLiquidObject.getString("Unit");
int TotalLiquidUnitType = TotalLiquidObject.getInt("UnitType");
// JSON Object (Rain Object)
JSONObject RainObject = getInfo.getJSONObject("Rain");
int RainValue = RainObject.getInt("Value");
String RainUnit = RainObject.getString("Unit");
int RainUnitType = RainObject.getInt("UnitType");
// JSON Object (Snow Object)
JSONObject SnowObject = getInfo.getJSONObject("Snow");
int SnowValue = SnowObject.getInt("Value");
String SnowUnit = SnowObject.getString("Unit");
int SnowUnitType = SnowObject.getInt("UnitType");
// JSON Object (Ice Object)
JSONObject IceObject = getInfo.getJSONObject("Ice");
int IceValue = IceObject.getInt("Value");
String IceUnit = IceObject.getString("Unit");
int IceUnitType = IceObject.getInt("UnitType");
// JSON Object (MobileLink Object)
JSONObject MobileLinkObject = getInfo.getJSONObject("MobileLink");
String MobileLink = MobileLinkObject.getString("MobileLink");
// JSON Object (Link Object)
JSONObject LinkObject = getInfo.getJSONObject("Link");
String Link_value = LinkObject.getString("Link");
System.out.println("Some of the outputs : " + Visibiliyt_value +"\n" + Visibility_Unit +"\n" + DateTimeValue ) ;
}
I uploaded a JSON example on :
http://m.uploadedit.com/bbtc/1512045722310.txt
(because of the post limit)
Would love to know what my mistake, been looking at it for a while now