Parse JSON in Ext JS 4 or JavaScript [duplicate] - javascript

This question already has answers here:
Parse JSON in JavaScript? [duplicate]
(16 answers)
Closed 10 years ago.
I have this type of JSON:
{"value":[{"idProductCategoryAttributeValue":43,"value":"7","sortOrder":0}]}
I want the individual parameters values like. How do I parse this JSON string in Ext JS 4 or in simple JavaScript?

Have a look at http://docs.sencha.com/ext-js/4-1/#!/api/Ext.JSON. There you find how you can parse JSON with Ext JS 4.
var strJson = '{"value": [{"idProductCategoryAttributeValue":43,"value":"7","sortOrder":0}]}';
var obj = Ext.JSON.decode(strJson);

var obj = Ext.decode(jsonstr);

Related

Parsing a stringified array to an array [duplicate]

This question already has answers here:
Parse JSON in JavaScript? [duplicate]
(16 answers)
Closed 9 months ago.
I have a component that throws the following in the backend
memberSince: [ '["2022-05-05T08:13:07.551Z","2022-06-01T08:13:07.551Z"]' ]
Is there a way to un-stringify the array content like memberSince[0].parse() or something
You can use JSON.parse()
const data = {memberSince: ['["2022-05-05T08:13:07.551Z","2022-06-01T08:13:07.551Z"]']}
const result = JSON.parse(data.memberSince)
console.log(result)

Text Array to Array in Javascript [duplicate]

This question already has answers here:
Parse JSON in JavaScript? [duplicate]
(16 answers)
Closed 3 years ago.
I need convert from data = "[[0,1], [1,1]]" to data = [[0,1], [1,1]] in javascript, remove double quotes . It's possible?
Thanks
Just use the JSON object:
data = JSON.parse("[[0,1], [1,1]]"); // data === [[0,1], [1,1]]

Javascript Turn string into array [duplicate]

This question already has answers here:
Parse JSON in JavaScript? [duplicate]
(16 answers)
Closed 7 years ago.
I want to turn this into an array
"["65747add-afd2-45b5-92e0-150bbe40e6d9", "9c247ea5-6b81-4f47-a50c-42367dedd50b", "c1555363-aca9-4e04-8844-e0180397c72e"]"
I am getting it from the page like this:
$('#layout-uuids').text()
Is there away to just get it as an array or do I need to turn the string into an array somehow?
Thanks!
That string looks like JSON. If it is indeed JSON, all you need is JSON.parse():
var someArray = JSON.parse($('#layout-uuids').text());

How to parse this json with jQuery [duplicate]

This question already has answers here:
How can I access and process nested objects, arrays, or JSON?
(31 answers)
Parse JSON in JavaScript? [duplicate]
(16 answers)
Closed 9 years ago.
Hi i am new to json and have some problems in parsing a JSON file with jQuery.
json file is here - http://maps.googleapis.com/maps/api/geocode/json?latlng=27.88,78.08&sensor=false
and i am parsing it like this
var url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + area.getCenter().lat + "," + area.getCenter().lng + "&sensor=false";
$.getJSON(url, function(data) {
console.log("insidegetjson");
console.log(data);
var addr = data.results[0].formatted_address[0];
});
here i want to access first "formatted_address" part of the JSON. I know i am making a mistake here (i want "formatted_address" : "Achal Taal, Aligarh, Uttar Pradesh 202001, India",)
var addr = data.results[0].formatted_address[0];
can you please replace this sentence with correct sentence...thanks
Remove the last [0] :
var addr = data.results[0].formatted_address;
data.results[0].formatted_address isn't an array but a string.

Convert JSON string to Javascript array [duplicate]

This question already has answers here:
Convert a multidimensional javascript array to JSON?
(9 answers)
Closed 2 years ago.
I have an array of arrays which I have planted in the DOM, so that I can reuse it at a later stage to transfer to the server:
[["1","aaaaaa","1"],["2","bbbbbbb","2"],["3","ccccccc","3"]]
If I would like to convert it back into a Javascript array, how would I go about doing this?
var obj = $.parseJSON('[["1","aaaaaa","1"],["2","bbbbbbb","2"],["3","ccccccc","3"]]')
Assuming jquery is ok to use because of tag.
If the browzer has the JSON object then
JSON.parse(string);
or if you have jQuery
$.parseJSON(string);
var array = JSON.parse(my_JSON)
jQuery.parseJSON()
var myArr = $.parseJSON(myJsonString);

Categories

Resources