Working with JSON objects in AngularJS

I have a JSON dataset in the following structure. I need to extract information from the JSON and display it on an HTML table.

[region:
    [name:"",
     code:""IntradayBalance:{   currency:,Time:,Balance:    }....
    ],
    acccountcurrencyBalance:[{ currency: ,Time: ,Balance: , 
        },...],]
    [country :  
        [name:"",
         code:""
        IntradayBalance:
        {   
            currency:
            Time:
            Balance:

        }....
    ],      
    acccountcurrencyBalance:[
    {
            currency:
            Time:
            Balance:    
    },...], 
]

I am trying to access data from "accountcurrencyBalance", but so far I have only managed to output the "region name". Here is the code snippet from my controller:

$http.get('data.json').success(function(data){$scope.response=data}

And here is my HTML code:

<ul ng-repeat="a in response">
    <li>{{a.region}}</li>
</ul>
<ul ng-repeat="a in response.accountcurrencyBalance">
    <li>{{a.accountcurrencyBalance.time}}</li>
</ul>

So far, it can only display the Region Name and not the data from account currency balance. Can anyone please assist?

Answer №1

First and foremost, it appears that your JSON data is not valid.

An example of valid JSON would look like this:

{"data": [{"id": 1, "name": "name1"}]}

Furthermore, make sure to access data.data within the success function. Be sure to review the documentation for $http for more information:

$http.get('data.json').success(function(response){
    $scope.response=response.data; 
}

Answer №2

What do you think about this code snippet:

<ul ng-repeat="a in response">
    <li>{{a.region.acccountcurrencyBalance}}</li>
</ul>

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

The $route object in Vue is not configured

Currently, I am delving into the realm of Vue router and aiming to achieve programmatic navigation without relying on <router-link> in my templates file. Here is a glimpse of my router and view setup: router = new VueRouter({ routes: [ ...

A particular character is displayed exclusively in a text box using either jQuery or JavaScript

Text Box <input id="txtbo" type="text" value="CAN'T TOUCH THIS!" size="50" /> Solution Using jQuery or Javascript: var readOnlyLength = $('#txtbo').val().length; $('#txtbo').on('keypress, keydown', function(even ...

Best practices for handling null variable assignment in DataWeave

Converting true/false JSON input to Y/N char output is the goal of this transformation. varOutput: ('Y' when payload.varInput otherwise 'N') However, what happens if varInput is null? An exception might occur. To handle this, we can a ...

Using ASHX to Return JSON in ASP.NET

I have implemented autocomplete functionality on my website. The JavaScript part is complete and I am able to retrieve the MembershipUser object of the matching user. Now, I need to format the JSON response as follows: { query:'Li', suggestio ...

Error occurred while retrieving JSON data due to utilizing null check operator on a null value

I'm having trouble understanding this code. builder: (context, snapshot) { if (snapshot.data != null && widget.stored!.b) { return new GridView.count( children: List.generate(snapshot.data!.length, (index) { r ...

Parsing precise decimal values from JSON file using Java

I have a JSON document structured like this. { "name": "Smith", "Weight": 42.000, "Height": 160.050 } To process this file, I've created the following Java code. import org.json.simple.JSONOb ...

What steps do I need to take in order to integrate an mpg video onto my

I am in need of embedding mpg (dvd compliant mpeg2) movie files onto my webpage. Unfortunately, I do not have the ability to convert these videos into any other format. This webpage is solely for personal use, so any solution would be greatly appreciated. ...

What is the best way to send information using an array of objects?

In my Angular 5 project, I am using the ngx select dropdown package (https://www.npmjs.com/package/ngx-select-dropdown) and I'm wondering how to pass an array of objects instead of an array of strings. Currently, when I do so, it displays [Object Obje ...

Angular: How come my filter only functions properly when implemented in a less efficient manner?

Let's get this done quickly, my dear friends I'm facing an issue with a filter in my code. Interestingly, it doesn't work when I follow the recommended method, but if I use another approach - which is not considered proper - the filter work ...

The equivalent of an event listener in event handling

Here is an example of how to set up event listeners: document.getElementById("A").addEventListener("change", function (e) { // do something when A changes }, false) document.getElementById("B").addEventListener("click ...

Limit the options in jQuery UI auto-complete to search by name from a variety of JSON responses

I am looking to enhance my search functionality by utilizing jqueryUi's auto-complete feature to specifically target Names and exclude other array values such as fax. Here is how I have implemented it in php: <?php require_once 'db_conx.php&a ...

Transform the input value into a string

Struggling with converting an input value into a string. HTML: <input type="text" placeholder="Email Ex: john123" id="emailinput"> <input type="text" placeholder="Domain Ex: @gmail.com" id="domaininput"> JS: let emailVal = document.getElem ...

Ways to retrieve an array saved in another JavaScript document

I am in the process of developing my own lorem ipsum application and keen on maintaining clean code by storing my word bank in separate files. How can I retrieve an array stored in a different JavaScript file? Rather than manually inputting harry = ["", "" ...

Validating multiple input fields using Javascript

Initially, I must ensure that the ID and password textboxes are not empty (which is functioning correctly). Following that step, I need to verify on the same form that the ID entered in the textbox is a numeric value within the range of 3000 to 3999 (tha ...

Retrieve the row id from the table by clicking on a button in a modal box using jQuery

I am encountering a challenge with a small task due to my limited experience in jQuery. I have a table where each row has an icon. When the icon is clicked, a modal box appears with some content. After closing the modal box, I want to retrieve the table ro ...

Stop ui-router from transitioning based on an HTTP query

Is there a way to prevent a state change for a specific "to" state in ui-router without using onEnter? Let's consider the following route: .state('auth.confirm', { url: '/confirm/:resetToken', template: '<confirm-page& ...

When there is only one value, the BehaviorSubject can be hit multiple times

Recently, I implemented BehaviourSubject in a shared service to retrieve the current value when clicking a button. Everything seems to be working fine, however, there are instances where the API call within the subscribe block of BehaviourSubject is being ...

Transform array sequences into their own unique sequences

Reorder Array of List to Fit My Custom Order Current Output: [ { "key": "DG Power Output", "value": "6.00", "unit": "kWh", }, { "key": "DG Run Time", "value": "5999999952", "unit": "minutes", }, { "key": "Fuel Level (Before)", "value": "8.00" ...

Prevent json.loads from changing the case of values to uppercase for true or false

Here is an example of some JSON data: "aaa": "play", "bbb": "fxc", "ccc": true, "ddd": "nat", "eee": "news", Whenever json.loads(my_json) is called on this string, the true value gets converted to True. Is there a way to prevent this conversion? ...

The functionality of "Overflow-scroll true" does not seem to be operational within an iOS device when using an Ionic application

Currently, I am working on an Ionic application and focusing on improving its performance. During my research process, I have come across various suggestions primarily related to scrolling functionality. It is highly recommended to use overflow-scroll="tru ...