[Solved] how i get title from following response [closed]

Assuming your JSON is assigned to a variable called response you can access the body with:let body = response.data.data[0].body And the title withlet title = response.data.data[0].title In case you want to loop over the data array in order to get a value for all entries (e.g. title), try this:let titles = response.data.data.forEach(entry => console.log(entry.title)); 0 … Read more

[Solved] Android : How to access a JSONObject

try this try { JSONObject obj= output.getJSONObject(“RESULTS”); JSONArray dataArray= obj.getJSONArray(“stationList“); for(int i=0;i<dataArray.length();i++)
{
 JSONObject object1=dataArray.getJSONObject(i); Strind id = object1.getString(“stationID”); } } catch (JSONException e) {
 e.printStackTrace();
 } In This code output is your JSONObject result 0 solved Android : How to access a JSONObject

[Solved] Add variable to json string in c#

Your question is not clear enough. But if I understand you correctly you want to convert this json { “fields”:{ “ID”: ID, “Device Name”: deviceName } } into string. I strongly suggest you use serialization libraries and do not write json yourself. You can easily create a class or dictionary and serialize it to that … Read more

[Solved] Dynamically build JSON in Python [closed]

You can create a helper function to dynamically populate the values in a dict object with the necessary structure: from __future__ import annotations def build_api_request(names: list[str], first: str, last: str, email: str, mobile_no: str, country_code: str | int): return { “list_name”: ‘,’.join(names), “subscriptions”: [ {“first_name”: first, “last_name”: last, “email”: email, “mobile”: {“number”: mobile_no, “country_code”: str(country_code)}} … Read more

[Solved] Replace string array in a JSON to integer array [closed]

const data = {“chart”: {“type”: “column”},”credits”: {“enabled”: true,”href”: “#”,”position”: {“align”: “right”,”verticalAlign”: “bottom”,”y”: 0},”text”: “www.midasplus.com”},”series”: [{“color”: {“linearGradient”: {“x1″: 1,”x2″: 0,”y1″: 0,”y2″: 1},”stops”: [[0,”#9a1919″],[“0.25″,”#9a1919”],[“0.5″,”#9a7319”],[“0.75″,”#9a1919″],[1,”#9a1919″]]},”data”: [“-1.03″,”-3.01″,”-2.25″,”0.63″,”-1.07″,”1.14″,”-0.38″,”2.03″,”-2.07″,”-3.55″,”-3.99″,”-0.41″],”negativeColor”: {“linearGradient”: {“x1″: -1,”x2″: 0,”y1″: 0,”y2″: -1},”stops”: [[0,”#199A19″],[“0.25″,”#199A19”],[“0.5″,”#00CC00”],[“0.75″,”#199A19″],[1,”#199A19″]]},”showInLegend”: “false”}],”title”: {“text”: “Control Chart”},”xAxis”: {“categories”: [“Q3 2013″,”Q4 2013″,”Q1 2014″,”Q2 2014″,”Q3 2014″,”Q4 2014″,”Q1 2015″,”Q2 2015″,”Q3 2015″,”Q4 2015″,”Q1 2016″,”Q2 2016”]} } const floatArr = data.series[0].data.map(item => { … Read more

[Solved] Alert view with JSON data [closed]

Don’t use NSDictionary in swift. Use [String:Any]. Get all values of the dictionary and join the array of strings. And join the error with a new line as a separator. let jsonObj:[String: Any] = [“error”: [ “email”: [“The email has already been taken.”], “phone”: [“The phone has already been taken.”]] ] if let errorMsgs = … Read more

[Solved] how to add object in nested array of objects without mutating original source

Use Array.prototype.map instead, forEach gets no returns let newobj = [ { id: 22, reason: ‘reason 2’, phase: ‘phase 2’, reviewer: ‘by user 2’, date: ‘date 2’ }, { id: 21, reason: ‘reason 1’, phase: ‘phase 1’, reviewer: ‘by user 1’, date: ‘date 1’ } ]; let arr1 = { initiateLevel: true, parent: [ { … Read more

[Solved] Android Saving JSON response in Sharedpreferences

Use this class for your purpose with files ! Hope it will help you ! public class MyJSON { static String fileName = “myBlog.json”; public static void saveData(Context context, String mJsonResponse) { try { FileWriter file = new FileWriter(context.getFilesDir().getPath() + “https://stackoverflow.com/” + fileName); file.write(mJsonResponse); file.flush(); file.close(); } catch (IOException e) { Log.e(“TAG”, “Error in Writing: … Read more

[Solved] Why does my JSON request fail more than 50% of the time? [closed]

There is not enough information to debug this specific problem but it is likely that the JSON response you are receiving has optional fields. Fields that are expected to be empty for certain responses. This part of your code, if let dictionary = jsonData as? [String: Any], let results = dictionary[“results”] as? [[String: Any]], !results.isEmpty, … Read more

[Solved] Get value from JSON in Python [closed]

you can do that as follows: d = {“coord”: {“lon”: -71.06, “lat”: 42.36}, “weather”: [{“id”: 500, “main”: “Rain”, “description”: “light rain”, “icon”: “10n”}], “base”: “stations”, “main”: {“temp”: 1.69, “feels_like”: -1.22, “temp_min”: 0, “temp_max”: 3.33, “pressure”: 1013, “humidity”: 94}, “visibility”: 16093, “wind”: { “speed”: 1.5, “deg”: 230}, “rain”: {“1h”: 0.25}, “clouds”: {“all”: 90}, “dt”: 1582094044, “sys”: … Read more

[Solved] How to get an string array from JSON arrays? [closed]

First of all you need to convert the raw response from the server to a Swift Dictionary. let payload = [ “cars”: [ [ “color”: “red”, “model”: “ferrari”, “othersAtributes”: “others atributes” ], [ “color”: “blue”, “model”: “honda”, “othersAtributes”: “others atributes” ], [ “color”: “green”, “model”: “ford”, “othersAtributes”: “others atributes” ], [ “color”: “yellow”, “model”: “porshe”, … Read more

[Solved] Convert JSON to array in Javascript

You could splice the values and get only the first two elements as number. var array = [{ time: “18:00:00” }, { time: “10:00:00″ }, { time:”16:30:00” }], result = array.map(o => o.time.split(‘:’).slice(0, 2).map(Number)); console.log(result); .as-console-wrapper { max-height: 100% !important; top: 0; } If you have JSON sting, then you need to parse it with … Read more

[Solved] How do you merge two javascript objects [duplicate]

There are quite a few npm packages out there to accomplish this, but one that is very popular is lodash.merge. Take a look at the lodash merge function: https://lodash.com/docs/4.17.4#merge This method is like _.assign except that it recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. Source properties … Read more