Context I am using: Windows 11, VSCode and node v18.12.1 The code I am working on is trying to traverse several JSON objects. Then, using an array variable, the code needs to filter on certain attributes in each object, as there is more than one value that needs to filter against in each name attribute in each object. Question The
Tag: json
How can I fetch a specific array from the JSON data and display it?
Firstly apologies as I am fairly new to fetching from an API and I am trying to learn. I need to fetch “name” , “age” and “phone” from “id” 1 from “is” and display it when click on button. This is my javascript-fetch-api.js file: I’m not sure how to fetch only from id 1 “is” Answer inside event you have
Convert 2D JS array to json string
My array in variable is: I’ve mentioned key and value here for the 2D array, I’m trying to convert this to JSON string. I tried JSON.stringify(arraydata), arraydata is the variable where the array is stored, but it makes the string empty, whereas array data is correct. Edit: This is how I’m adding array data: Answer The “array” quoted in your
Extend JSON object by multiple JSON levels
trying to extend existing empty JSON object. After first 2 simple extends I will get {size: 10, from: 0}. But when trying $.extend function with multiple level JSON I have no success. But getting “Uncaught SyntaxError: missing ) after argument list” error. I believe overlooked something simple but I am not able to find it. Answer Thanks to @Barmar I
printing arry of object in object in Html from JS and Json
I have an array in JSON, I need to pass it in JS that its printing will be like the image in HTML After trying to print to console.log – it really prints in order It’s just that during the creation of the HTML elements everything was a mess This is my array: And I want it to be printed
Replace (fix) non UTF-8 character in string
When I am parsing a string to become a JSON object there are some special characters that are replaced with the black question mark (�), I believe that is an issue with the encoding of the character. Is there any way of replacing the question mark with the correct character (é) or is it lost? Answer From the current version
Fetch local JSON and display a list in Next.js. Property ‘data’ does not exist on type String
I am trying to get the names displayed of a ‘Crate’ (a crate full of records/albums), derived from a local JSON file. But it’s not showing up. Should I be using params? Should I have not stringified the JSON? VSC tells me Property ‘data’ does not exist on type String. Before this I received an error that crates.map is not
Problem with JSON.stringify a tag outerHTML in multidimensional array
I’m trying to stringify a multidimensional array with some string and the outerHTML of an anchor tag. For some unknown (to me) reason, it adds a double to the outerHTML text resulting in invalid JSON. The result is: Answer you need to console.log it from experience, I can tell that you just copied this string from your dev console,
Json file data to Chart.JS
I’m trying to add multiple datasets from a json file to a linechart in chart.JS. Here’s my JS code: Here’s my HTML: All other neccessary HTML code is added to make the file valid. There is something wrong with this code i just can’t figure out, I’m able to use the charts to input manual data but when it comes
node.js find attributes with same value in multiple JSON files
Hey I would like to ask if it is possible to find lets say in 10 JSON files which are looking like this: 1.json: 2.json: And so on… just different attribute values. Lets say I want to find only towns with People > 2500 and I’m not even sure if it is possible or do I need to upload the