[Solved] Why am I getting this error ?? java.lang.ClasscastException

The top level object in your JSON file is an array so: class letsRead { public static void main(String [] args) { String inline = “”; try { URL url = new URL(“https://gist.githubusercontent.com/anubhavshrimal/75f6183458db8c453306f93521e93d37/raw/f77e7598a8503f1f70528ae1cbf9f66755698a16/CountryCodes.json”); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setRequestMethod(“GET”); conn.connect(); int responsecode = conn.getResponseCode(); System.out.println(“Response code is: ” +responsecode); if(responsecode != 200) throw new RuntimeException(“HttpResponseCode: ” … Read more

[Solved] How to Convert string response to array laravel

You should use json() method or object() method on your response variable. API Reference json method: Get the JSON decoded body of the response as an array or scalar value. object method: Get the JSON decoded body of the response as an array or scalar value. Usage: $response = Http::get(“www.api.com/…”); $decodedBody = $response->json(); OR $decodedBody … Read more

[Solved] Convert JSON object containing objects into an array of objects

This can be done for instance with two imbricated .forEach(): var obj = { “name”: { 0: ‘name0’, 1: ‘name1’, 2: ‘name2’ }, “xcoord”: { 0: ‘xcoord0’, 1: ‘xcoord1’, 2: ‘xcoord2’ }, “ycoord”: { 0: ‘ycoord0’, 1: ‘ycoord1’, 2: ‘ycoord2’ } }; var res = []; Object.keys(obj).forEach(k => { Object.keys(obj[k]).forEach(v => { (res[v] = (res[v] … Read more

[Solved] Creating C# class from Json

Actually, this is not that hard when you use the JsonProperty attribute public class Class1 { [JsonProperty(“icao”)] public string Icao { get; set; } [JsonProperty(“iata”)] public string Iata { get; set; } [JsonProperty(“name”)] public string Name { get; set; } [JsonProperty(“city”)] public string City { get; set; } [JsonProperty(“state”)] public string State { get; set; … Read more

[Solved] Can’t figured out json formating [closed]

Yes, it’s valid JSON. The value it represents is an object, not an array. The object has one property, whose key is “data”. The value of that property is an array of strings. solved Can’t figured out json formating [closed]

[Solved] How to extract JSON values that does not have attribute names?

Analysis XPath can’t read unnamed attributes. It will always result in an exception. If you want to get the values, you need to use JsonPath. Solution Even then, it makes sense to add surrounding brackets, otherwise the first level will be consumed as well: [ { “A1”:{ “name”:”Ad hoc”, “projectId”:0 }, “X2”:{ “name”:”BBB”, “projectId”:101 }, … Read more

[Solved] Can I parse my JSON data like this?

As you create an empty map, if you attempt to read “createdDate” you will get null as a result. This won’t throw any exception. However, in the next line you want to initialize a new Date object and pass dob1 (which is still always null). This will cause an IllegalArgumentException to be thrown. You could … Read more

[Solved] android FATAL EXCEPTION: AsyncTask #2 [closed]

URI website = new URI(“http://example=” + et.getText() + “json”); You didn’t connect your EditText et with it’s view. So et.getText will give you an error. URI website = new URI(“http://example=” + et.getText() + “json”); change it to URI website = uRI; and pass your URI while processing doInBackground like – String uRI = “http://www.example.com/example.json”; JSONObject … Read more