Skip to content
Advertisement

Tag: json

Javascript parse a string with commas

I am getting this string from my api call: I need to find a way to parse it and be able to iterate over the items in attachments list, but when I try to run JSON.parse(str) I am getting an error, I guess because the word attachments has commas around it. The error is Uncaught SyntaxError: Unexpected token ‘ in

How can I convert a LOG .txt to .json using JavaScript?

I’d like to know how can i convert a log to .Json using JS. Reading the data in the LOG and converting it to .json, i searched a lot and didnt find anything about it. Answer You can simply read from the .txt file then write the contents to a .json file using JSON.stringify to make sure characters such as

Convert JSON to different format using the javascript

I have the JSON please see below and I need help to convert changing the format mentioned below. I want to move the data to different columns (format mentioned below) JSON I have I want to change the above to the below format: Expected format Answer Here’s a solution that flattens arbitrarily nested json inputs, assuming only that each column

Split array data from fetch data

I fetch this data from the api then i want to split this into two array i try using split function but it didn’t work, when i check for array.length, console said it undefined. when i console.log(array) it show like this Help me please. Answer First, This is not an array it’s an object. You can use Object.keys and Object.value

Domo.js is trying to JSON.parse a png

While developing a custom app for my organization, I am trying to request the name and the avatar of the individual accessing the card. I am able to get the name of the individual without any problems, but when requesting the avatar image I get the following console error: Uncaught (in promise) Error: Invalid JSON response at XMLHttpRequest.d.onload (domo.ts:309:18) I

Access most recent value in JSON nested object with JS

I’m trying to access the most recent element in the Time Series (5 min) object, without having to specify the date/time, after using this JS code: So in this case (see screenshot) it’s Time Series (5 min) > 2022-04-21 20:00:00 -> 4. close, but I get an undefined error. I even tried in the developer console with the full JSON

How to append html id with for-loop?

I’m new to JavaScript and HTML. I’m reading my JSON file and appending it to each HTML ID but was wondering if there’s an easier way to do this by using a for-loop? Answer Iterating over the changing indicies of 0 to 4 would look to do the trick. If info.data will have the same number of items in the

Advertisement