Navigating through JSON in IonicIs this revised text acceptable?

Is it possible to iterate through a JSON structure like the one shown below in Ionic 3?

[
 {
   "date": "28/09/2017 08:03",
   "data": {
     "1": 10,
     "2": 0
   }
},
{
   "date": "28/09/2017 08:04",
   "data": {
    "1": 0,
    "2": 5
   }
}
]

I have attempted to loop through this data without success. The latest approach I tried is as follows:

this.data = returnedJson;

  for (let reportData of this.data.data) {
        console.log("Our Data : " + reportData);
    }

and

  for (let reportData in this.data.data) {
        console.log("Our Data : " + reportData);
    }

Answer №1

Give this a shot:

for (const element of this.data) {
    console.log("Data Item: " + element.data);
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to deserialize JSON with NewtonSoft when dealing with properties with the same name and arrays

Recently, I received a json result that looks like this: {"status":"1","message":"OK","result":{"status":"0"}} I am trying to extract the status value of 0. This is my code: public class GetTransactionStatus { [JsonProperty("result")] ...

Extract facial features and face textures from Blender for use in three.js

I'm encountering an issue while trying to import a Blender-designed mesh into my three.js project. After adding the io_three addon, I am now able to export json files for Blender. However, when I attempt to load the mesh using a THREE.JSONLoader, I ...

Searching through a JSON object for a specific key and its corresponding value to locate its child elements in Groovy

[ { "createTime": "2014-05-12 04:51:46.513343", "powered": false, "description": "s", "current": false, "children": [ { "createTime": "2014-05-13 03:50:43.050442", "powered": false, "descripti ...

Parsing multiple key-value pairs from JSON in Android

My current challenge involves working with a JSONObject structured as follows: {"message":{"context":"ws","data":"","id":"12345","http_accept":"json","method":"GET","search_key":"cat"},"response":{"1":"cat", "2":"catte"},"status":"OK","code":200}. I am c ...

Combining two arrays with varying lengths based on their values

Seeking assistance with a programming task that is straightforward yet challenging for me. There are two arrays: one long and one short. var arrayShort = [ { id: 'A', name: 'first' },{ id: 'B', name: &ap ...

Locating a particular JSON field value without the need for a model class

I need a way to extract a specific value from a complex json structure without having to create a Model class. I can currently read it using Newtonsoft, but that requires a model. Given that I have numerous different JSON models, is there a way to directly ...

In C#, you should assign the returned value from JavaScript to an array

I am in need of assistance with a javascript function that returns an array. My main queries are: (a) How can I call the Javascript function during OnInit or Onload? (b) The javascript function outputs an array, and I would like to store it within an ar ...

PHP is having trouble parsing values from keys in JSON data retrieved from an external API

I'm currently working on making an external API call to retrieve JSON data and display it in my web application. Here is a snippet of the JSON data obtained from the API call: JSON returned from URL: { "results":[ { "name":"Company1", "Prov ...

The property 1 cannot be added because the object is not extendable in React

Does anyone know what is causing the following issue? I am unable to insert a new object into a key object within my arrays of objects. For example, when I try to insert a new email at index 1 in the 'emails' array, it throws an error stating "ca ...

After clicking the button, I need to extract the ID from the JSON response and then include it in the POST method for sending it again

When parsing the JSON data, I have an ID, content, title, and count. I want to exclude displaying the ID initially, but upon clicking a button, I need to retrieve the ID value and send it to the server side. This is how my JSON parsing values look like: ...

Tips for extracting nested JSON data and generating a streamlined JSON in Snowflake

Here is the structure of my current JSON object: -- Creating a sample table create or replace table json_example(v variant); -- Inserting a sample JSON record insert into json_example select parse_json( '[ { "key": "va ...

Updating Select Options Disabled/Enabled in Angular 2

In my Angular2 project, I have 2 select elements: <div ng-controller="ExampleController"> <form name="myForm"> <label for="companySelect"> Company: </label> <select name="companySelect" id= ...

Developing a script to extract a specific key from a JSON object and then using the urlparse function on its corresponding

After retrieving a JSON data structure, I encountered the following: [ { "weburl": "https://google.com/athens", "location": "Greece" }, { "weburl": "https://google.com/rome", "location": "Italy" } ... ] The goal is to ...

Using Python to retrieve .json data from Splunk

Here's the issue I'm facing: I uploaded a json file to splunk for my university project, and now I need to use it in python as a dataframe object. Code: import urllib3 import requests import json import pandas as pd urllib3.disable_warnings(u ...

Troubleshoot an Office add-in using VS Code

Looking for guidance on Office add-ins and VS code... I recently went through the steps outlined in this tutorial by Microsoft to create an Excel custom functions add-in. To debug it using VS code, I had to select TypeScript as the script type while creat ...

Leveraging the json4s-native library within a distributed Spark environment

In my AWS EMR Spark cluster, I am working on processing data with a Scala application. The application reads raw JSON data from S3 and uses Scala's scala.util.parsing.json.JSON library along with the parseFull method to parse it into Map[String, Any]. ...

Exploring the world of JSON manipulation in Libgdx

Dealing with an issue regarding JsonBeans in Libgdx. I am attempting to save and load game progress using local storage. Here is how I am initializing the file: file = Gdx.files.local(FILENAME); When trying to read the json data: if (file.exists()) { ...

Instructions for activating "error prevention only" in TSLint: How can you turn off style checks and other features?

After creating and running my first Vue.js + TypeScript project, I decided to reformat the TypeScript code to my liking. However, when I ran the npm run serve command, I received the following warning: WARNING in .../src/app/app.ts 7:1 misplaced opening b ...

Implementing a more efficient method for incorporating UUIDs into loggers

------------system1.ts user.on('dataReceived',function(data){ uniqueId=generateUniqueId(); system2.processData(uniqueId,data); }); ------System2.ts function processData(u ...

iOS6: Using POST method to send JSON data from an iPhone to a REST API

I have encountered an issue while trying to send data in JSON format to a REST API. The web service does not return any data when sending a parameter and instead shows the error message: Error parsing JSON: Error Domain=NSCocoaErrorDomain Code=3840 "The op ...