Exploring JSON objects within other JSON objects

As I work on my Angular App and implement angular translate for dual language support, I've encountered an issue with accessing nested items within my JSON object.

After carefully constructing my JSON and verifying its validity, I attempt to retrieve data beyond the first level, only to receive undefined values.

For example, consider the structure of my angular translations JSON:

$translateProvider.translations('en', {
 "SEARCH": {
    "SEARCH" : "Recherce",
    "ABILITY" : "Abilities",
    "MANAGEMENT" : "Management Competencies",
    "PERSONAL" : "Personal Suitability"
 },

 "ABILITIES": {
    "TITLE" : "Test Title here",
    "ADVISORY": {
      "TITLE" : "Advisory Skills",
      "QUESTIONS": [
        {
          "TYPE" : "A",
          "LEVEL" : "45",
          "DESCRIPTION" : "Can you tell me how awesome you are"
        },
        {
          "TYPE" : "B",
          "LEVEL" : "100",
          "DESCRIPTION" : "Tell me about your wicked project"
        }
      ]
    }
  },

  "HEADLINE": "Oh No!",
  "SUB_HEADLINE": "Looks like you are not amazing"
});   

To access the JSON data, I first initialize it with:

list = $translateProvider.translations('en');

When checking if the data is correctly retrieved by outputting in the console, I run the following:

console.log(list);
var getTitle = list.HEADLINE;
var getSearch = list.SEARCH.ABILITY;
console.log(getSearch);
console.log(getTitle);

The results show a surprising inconsistency.

The 'list' displays the intended JSON array

Retrieving HEADLINE yields Oh No!

However, attempting to access list.SEARCH.ABILITY returns undefined

This raises the question of why this occurs, especially considering the deeper nesting of data under "ABILITIES".

Note that Angular Translate utilizes the syntax

{{ 'ABILITIES.ADVISORY.TITLE' | translate }}
to render JSON content on the HTML page.

Answer №1

attempt list.DISCOVER["SKILL"].result

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

Creating a Vue.js component that integrates a Bl.ocks.org graph

I'm a rookie in the world of D3 and I am trying to implement this cool d3 element into my Vue.js component. However, I've encountered an issue with the periodic rotation that I require not functioning properly. It seems to work initially but then ...

When attempting to install React Native on a Mac using the "npx react-native init MyTestApp" command, the

PROBLEM I am encountering difficulties while attempting to install and execute the react native todo command - npx react-native init MyTestApp on my MacBook Pro. The specific challenges I am facing are: The detailed github issue can be found here: here ...

Server Sent Events not being received by client from Express.js server

My Next.js (React) client is set up to receive Server-Sent Events from my Node.js/Express.js server, but it seems like it's not receiving any messages for some unknown reason. While the open and error events of EventSource are functioning correctly, ...

Disregard all numbers following the period in regex

I have developed a function to format numbers by adding commas every 3 digits: formatNumber: (num) => { return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') }, The issue with this function is that it also add ...

Accessing the element within an ion-tab using document.getElementById

Within my ion-view, I have ion-tabs containing a canvas element. However, when attempting to retrieve the canvas using document.getElementById('photoCanvas'); I receive 'undefined'. Here is the code snippet: HTML: <ion-view ...

I am looking to retrieve a specific input value from a JSON array using JavaScript

I have created an array called 'PROPERTIES' which accepts values like username, password, sid, etc. I am looking to retrieve these entered values using JavaScript. 'PROPERTIES': {'gatewayurl': {'Name': ...

Navigating through nested objects in React can be done by using dot notation or

Why are some attributes accessible at the first layer of this weather object, but not at the second layer? Take a look at the image for the object below. Here is the code snippet: const Weather=(props)=>{ const{capital, api_key} = props ...

What is the best way to access a key from an object within the map function?

What is the method to extract the key from an object in ReactJS? {this.state.data.map((object, index) => ( <div>{Object.keys(object)}</div> ))} For example, if this.state.data contains: [{mykey1:23},{mykey2:24},{mykey3:34}] T ...

Is there a way to modify this within a constructor once the item has been chosen from a randomly generated array?

If I use the following code: card01.state = 3; console.log(card01); I can modify the state, but I'm interested in updating the state of the card chosen by the random function. class Item { constructor(name, state) { this.name = name; thi ...

What could be causing my token to not save after registering a user?

I am currently facing an issue when submitting a registration form. While the user is successfully created, the token is not stored in localStorage, which prevents me from being redirected immediately to the app and forces me to log in again. Here is my R ...

I am facing an issue with the Tailwind Flowbite Datepicker dropdown UI when running "npm run prod" for minification. The class is not being added during minification on the npm

I have successfully integrated a Laravel project with Tailwind CSS. I have also implemented the Flowbite Datepicker using a CDN to include the necessary JavaScript. Initially, everything was working fine and the date-picker was displaying correctly. Howev ...

Using the attribute to pass an object to a directive and including a variable inside

Is it possible to transfer $scope.data to a directive through its attribute in an Object, without using separate attributes? I would like to achieve the below format with any solution. <custom-directive detail="{index:1, data: {{data}}}"> </custo ...

Discovering which particular check in the Express Validator is causing the errors can be done by following these steps

I am currently developing a web application that requires an admin user to create new users. The admin user's username and password are stored in the .env file, and I am utilizing the dotenv package for this purpose. However, I am facing an issue when ...

Retrieving values with a variable serving as the key

My goal is to utilize the object key as a variable in my code. I've successfully extracted the object key (c000_01), but now I need to access the corresponding value of that object, which is "Master". Below is a snippet of the data structure: const ...

What are the methods for providing both successful and unsuccessful promises, with or without data?

Seeking guidance on how to return a promise and an object named output before or after the $http call in AngularJS, specifically using Typescript. How can I ensure it works correctly? topicNewSubmit = (): ng.IPromise<any> => { var self = t ...

I'm experiencing unexpected behavior with the <form> element in React, it's not functioning as I

I have encountered a strange behavior while trying to implement a form element for user input. When I directly insert the form element, everything works perfectly fine as I type in the letters. However, if I insert the form element through the AddForm comp ...

Modifying an image's height and width attributes with jQuery and CSS on click action

I'm currently developing a basic gallery using HTML, CSS, and jQuery. The objective is to have a larger version of an image display in a frame with an overlay when the user clicks on it. While this works flawlessly for horizontally-oriented images, ve ...

Loading data from JSON files into Postgres tables

In one of my database columns, I have arrays stored as text which look like this: ID | My_data 0 | [[A, 0.1], [B, 0.1]] 1 | [[A, 3.2], [B, 1.1]] : | : 99 | [[B, 0.2], [A, 4.4]] It's important to note that the order of data in these arrays is not ...

Bootstrap encountered an issue with altering header information

I've been trying to set up a notification system that plays a sound every time someone makes a new post. I'm working with Bootstrap 4 and I've tried inserting JavaScript into the functions page, but no matter how many times I call the ' ...

View the Sub content from a ngFor Array upon clicking

For my project, I have a scenario where each card value is displayed on the screen by looping over JSON data using ngFor. The objective is to show specific information from the JSON when a user clicks on a card, utilizing *ngIf to display content only in a ...