The JSON array is causing the statement to not compile

I am working with a Json array structured like this:

Test = [
     {
      "adj" : [
                {
                  "nodeTo" : "x",
                  "nodeFrom" : "y",
                  "data": 
                      {
                        "$type" : "line",
                        "$color" : "#A989BC",
                        "$value" : "number"
                      }
                 }
               ],

      "id" : "id1",
      "name" : "name1"
     },
     {
      "adj" : [ ..... ]   // There are multiple elements in the Test array

I am attempting to iterate through all the elements in the Test array. Here is my current approach:

list = [];
for (i = 0; i < Test.lenght; i++) {
    if (x == Test[i]["name"])
           list.push(x + "->" + Test[i]["adj"][0]["nodeTo"] + ":" + Test[i]["adj"][0]["data"]["$value"]);
 }

However, I am encountering issues with this method and it is not producing the desired results. Any help or suggestions would be greatly appreciated. Thank you in advance :)

Answer №1

It's most likely just a simple typo you made here: i < Test.length;

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

Ext JS - A grid cell containing varying values, accompanied by a selection of combo boxes

I'm currently implementing the Ext JS Grid component and have a list of fields with their respective data types: ID (int) Name (string) Foods (List<string>) Each user can have multiple foods, selected from a Food DataStore. Displaying this in ...

Utilizing AJAX with a combination of JSON and HTML data types

I recently completed a tutorial on ajax and implemented a script that retrieves JSON data and appends it to a table. $.ajax({ url: 'insert.php', type: 'POST', data: {data1: name, data2: phone, data3: address}, dataTyp ...

Converting Comma Separated Values to neatly organized JSON using Python

After struggling with my CSV file structure which looks like this: Store, Region, District, MallName, Location 1234,90,910,MallA,GMT 4567,87,902,MallB,EST 2468,90,811,MallC,PST 1357,87,902,MallD,CST I managed to reformat it with a lot of iteration into ...

Steps for converting TypeScript code to JavaScript using jQuery, without the need for extra libraries or frameworks like NPM

My single-page dashboard is quite basic, as it just displays weather updates and subway alerts. I usually refresh it on my local machine, and the structure looked like this: project/ index.html jquery-3.3.1.min.js script.js I decided to switch it t ...

The elements in my code are not displaying as expected

This is my jQuery script: $("#options").popup(null, Settings.DialogOptions) .on("onOk", function(){ Settings.SaveSettings( ); Settings.CloseSettings( ); switch(Settings.GetSetting("displayId")){ case "true": $("#nextId").s ...

The dynamic change of a required field property does not occur

I am facing an issue where one of my fields in the form should be mandatory or not based on a boolean variable. Even if the variable changes, the field always remains required. I'm puzzled about why my expressionProperties templateOptions.required is ...

What is the reason behind installing both Typescript and Javascript in Next.js?

After executing the command npx create-next-app --typescript --example with-tailwindcss my_project, my project ends up having this appearance: https://i.stack.imgur.com/yXEFK.png Is there a way to set up Next.js with Typescript and Tailwind CSS without i ...

Tips for invoking an async MVC controller function using ajax

Within my controller method, I am performing a database lookup for the logged-in user and then sending a confirmation email. Here is the code snippet: [HttpPost] public async void ResendConfirmationEmail(string username) { var user = await Usermanager ...

Steps for exporting various elements from a .vue file

In my Vue project, I am incorporating TypeScript along with Vue. There is a specific scenario where I need to export multiple items from my .vue file. Here's an example of what I want to achieve: // FooBar.vue <template> ... </template& ...

The KoGrid filter is malfunctioning when used in conjunction with Plunker

I'm currently facing an issue with the filter functionality on the knockoutjs ko grid. There are a couple of issues that I've encountered: Firstly, the drop-down menu for the filters displays "Choose columns" but the column names get cut off at ...

Manipulating JSON data by replacing values with other JSON data in Python

When working with a nested JSON object, the goal is to modify values and add a new JSON Object. Consider the following JSON Object: { "key1": "value1", "key2": { "key2_1": "value2_2 ", ...

Utilize Element-UI to effectively close dropdown menus

In my Vue application with ElementUI, I have a drop down menu that needs to be explicitly closed after some logic is applied. The process is as follows: User loads the page, selects a name from the drop-down - the name value is saved in the database User ...

Encountering a Type Error with Webpack4 when running npm start

When I run `npm start` on my Vue project, everything seems okay, but when I open the browser page, it shows up blank and gives me an Uncaught error: TypeError: Cannot read property 'call' of undefined The console view displays the following e ...

Converting Coordinated Universal Time (UTC) to local Unix time: A step

I am currently working on a React application that includes a survey component. When a user decides to skip the survey, I want it to reappear after a certain amount of time has passed (measured in days or hours). The rejected time is provided in UTC format ...

Monitoring the advancement of an Angular 2 service call

It has been mentioned to me that we utilize services to communicate with the database or other data storage systems. During the query execution, I am interested in displaying a progress bar on the user interface. What is the best way to monitor and track ...

When attempting to insert a date into a MySQL database using React.js, I encountered an issue with the date format

Hey everyone, I have set the input date to dd/mm/yyyy format using moment(donors.donateDate).format('DD-MM-YYYY'). However, when I click the submit button, an error is displayed in the console stating: The specified value "23-03-2022" ...

Having trouble with updating AngularJS?

I am facing an issue while updating the guitar object in my AngularJS application. The operation is performed using the updateGuitar controller with ngMock backend. After updating the guitar object, the put request is processed by the carService. However, ...

Switch the Angular app written in Javascript to Typescript

I am looking to create a pluginable Angular app and came across this tutorial that uses RequireJs for loading scripts in the correct order. Now, I want to convert this project to TypeScript but I am unsure of how to incorporate RequireJs into TypeScript. ...

Customize Input Values by Selecting an Option with jQuery-UI Autocomplete

Hello there, I am a newcomer to java-script and could really use some help. My goal is to have the data in the country field automatically populated when a user enters data into the city field. I have an xml file: <ROWSET> <ROW> <city>&l ...

flylatex is struggling to locate some modules

When I try to run flylatex from github on Debian and Ubuntu, I encounter the following Error. I'm not sure if there's an issue with my nodejs setup or if flylatex itself has an error. To troubleshoot, I initially ran npm install -d in the working ...