Key within square brackets in a JSON array

I am dealing with a JSON array that includes a square bracket in the key, like this:

{
  "msg":"OK",
  "data":[
    {
      "nls!type":"NCR",
      "current":"Assign",
      "physicalid":"0FFE0001000009FC5BD6805C00001352",
      "attribute[custTitle]":"Title",
      "name":"181002",
      "description":""
    }
  ]
}

My question is, how can I access the value of "attribute[custTitle]" in JavaScript?

When attempting to retrieve arrData[i].attribute[custTitle], I am encountering an error stating that custTitle is not defined. However, I am able to access the other values in a similar manner without any issues.

Answer №1

give this a shot

const result = {
  "message":"Success",
  "info":[
    {
      "type":"NCR",
      "status":"Pending",
      "id":"0FFE0001000009FC5BD6805C00001352",
      "attribute[title]":"Title",
      "number":"181002",
      "details":"" 
    }
  ]
};

console.log(result.info[0]['attribute[title]']);

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

Customize the filename and Task Bar name for your Electron app when using electron-packager

My application uses electron packager to build the app on Mac. Here is my package.json configuration: { "name": "desktop_v2" "productName": "desktop v2", "version": "1.0.0", "license": "MIT", "scripts": { "build": "node --max_o ...

`Using Twitter Bootstrap in mobile app development with javascript`

I have been utilizing Twitter Bootstrap 2.3 on one of my websites and I appreciate its responsiveness and use of media queries for mobile devices. However, I have noticed a lack of mobile-specific features, particularly linked listviews. In order to addres ...

The JSON request was unsuccessful in sending the JSON object to PHP, resulting in an empty var_dump

I am encountering an issue where my $_POST array in PHP is empty when I try to pass a JSON object with an AJAX request on my JavaScript page. Here is the JavaScript code: function send(cat, subcat) { var type = cat.options[cat.selectedIndex].text ...

Is there a simple method for transforming tabular data from an Excel spreadsheet into JSON format?

I'm looking to transform data from a spreadsheet in either Excel or Open Office that's saved as *.xls into *.json format. The information is not confidential The file size is manageable ...

Error message: jQuery expression not being detected

Here is some html code that I have in my view: <div id="divLoginName" style="display: none"> <input type="hidden" id="hidLoginName" /> @Html.TextBox("txtEditLoginName", null, new { maxlength = "1000", tabindex = "0", Multiline ...

The ngOnInit function is not triggered upon instantiation of an Injectable class

What could be causing the ngOnInit() method not to be called upon resolution of an Injectable class? Code import {Injectable, OnInit} from 'angular2/core'; import { RestApiService, RestRequest } from './rest-api.service'; @Injectable ...

Add a unique CSS style to both text and image using anchor tags

Why isn't the hover effect of color transition and underline being applied to the image? It seems to only work for text. While I understand that the color transition may require a change in image color, shouldn't the underline still occur? This ...

How to use multiple template urls in Angular 6

Currently, I am creating a front-end using Angular 6 and facing the challenge of having components with varying html structures based on the user who is logged in. The number of templates required can range from 2 to over 20, so my preference would be to ...

"The AJAX response returned a status code of 200, however, the PHP script being executed on the XAMPP localhost did not provide

The HTML code initiates a localhost function called getNodes which returns JSON data that is verified by JSON lint. However, when the same function is invoked using AJAX from a JavaScript file, a 200 response code is received without any response data. I h ...

Angular is not programmed to automatically reflect updates made to my string array

let signalRServerEndPoint = 'https://localhost:44338'; this.connection = $.hubConnection(signalRServerEndPoint); this.proxy = this.connection.createHubProxy('MessagesHub'); this.proxy.on("ReceiveMessage", (message) => { ...

How to change a date object into a datestring using the TZ format in JavaScript

Here is the input: const date = "06/01/2018" const time = "06:25:00" The desired output format is a string like this: "2018-06-01T00:55:00.000Z". I attempted to create the Date object using const result = new Date(date + time); //outputs an obje ...

Pop-up - maintain the initial value

I'm working on a modal using Bootstrap and React. Inside the modal, there's a dropdown with an initial empty option: <select class="form-control" onChange={this.handleSelectCat}> <option disabled selected></option> < ...

I'm encountering an issue where it appears that my ajax method may not be effectively communicating with my webservice

I am currently working on calling a webservice using an ajax request with the intention of retrieving clinical cases within a specific date range (for example, between 2015-01-01 and 2016-06-08). The webservice functions perfectly when tested individually. ...

JavaScript retrieve data from an external JavaScript file

How can I retrieve the id value from my rendering.js file? <script type="text/javascript" src="./js/rendering.js?id=3"> I am trying to access the id value in my rendering.js script. Any suggestions on how to accomplish this? ...

I am experiencing difficulty selecting a precise geolocation using a Postgres query

I'm currently working on an API and encountering a frustrating issue. Whenever I execute the following query: SELECT * FROM u.loc It retrieves all user locations along with additional data, including a parameter called "geocode": ex. "geocode":"(48 ...

Encountering a Next.js event type issue within an arrow function

After creating my handleChange() function to handle events from my input, I encountered an error that I'm unsure how to resolve. Shown below is a screenshot of the issue: I am currently working with Next.js. In React, this type of error has not been ...

Modify the values in a textbox using JavaScript to suit your needs

unusual issue: I'm encountering a strange bug with my form. I have an ajax datepicker attached to a text box, but when I submit the form, all values are received except for those from the datepicker checkboxes. Why is the .Text property empty for th ...

"Ensuring Username Uniqueness in AngularJS and CakePHP3: A Step-by-Step

<input type="email" id="username" dbrans-validate-async="{unique: isUsernameUnique}" ng-model="username" required class="form-control" name="username"> $scope.isUsernameUnique = function(username) { $http.get(url+'/isUsernameUnique&apo ...

Interaction between index file and module instance

As I develop a computer system, I have divided it into various smaller components. My experience in software development has taught me the value of keeping systems compact and focused. To achieve this, I am creating modules that perform specific function ...

How can JSON arrays be utilized for smooth communication between a Windows Phone 7 device, a MYSQL database, and a PHP

Looking for a seamless way to connect my MYSQL database with PHP and JSON arrays. I need to send and retrieve data from the database using a Phone-7 app. Does anyone have experience with this type of communication in developing a Phone7 application? I am ...