The process of retrieving child data from a JSON object

I have a JSON object that I am attempting to iterate through, which is being returned via a Netsuite script.

The JSON object contains some child elements.

I am specifically trying to access the caption for data under "classnoheirachy - name", but I am unsure how to reach the innermost child.

I would like to understand how I can use JavaScript to display the values of classnoheirachy - name and classnoheiracy-internalId.

Currently, my code loops through the JSON object as shown below. If anyone knows how I can extract the information above and add it to a new array, your assistance would be greatly appreciated.

var rs = nlapiSearchRecord('item', 'customsearch_pm_item_record_loader', itemFilters);

response.write(JSON.stringify(rs));

var retObj = [];
for ( var i = 0; rs != null && i < rs.length; i++) {            
    var rowObj = {};
    rowObj.LOCATION = rs[i].getValue('location');
    rowObj.LOCATION_AVAILABLE = rs[i].getValue('locationquantityavailable');
    rowObj.CLASS = rs[i].getValue('classnohierarchy');
    rowObj.CURRENCY = rs[i].getValue('currency', 'pricing');
    rowObj.UNIT_PRICE = rs[i].getValue('unitprice', 'pricing');
    rowObj.LOCATION_ON_HAND = rs[i].getValue('locationquantityonhand');
    rowObj.ITEM = rs[i].getValue('itemid');
    rowObj.ITEM_NAME = rs[i].getValue('itemid');
    rowObj.PRICE_LEVEL = rs[i].getValue('pricelevel', 'pricing');
    rowObj.ITEM_DESCRIPTION = rs[i].getValue('salesdescription');
    retObj.push(rowObj);
}

Answer №1

Consider trying something along these lines:

rowObj.Name = rs[i]['columns']['classnohierarchy']['name'];
rowObj.InternalId = rs[i]['columns']['classnohierarchy']['internalid'];

Check out this Fiddle Here for a demonstration

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

Checking links stored in an array using JavaScript

I am currently working on a JavaScript function that will iterate through an array of URLs to find a 'pingable' URL and return its index. Here is the code snippet I have so far: function ping(url: string): Promise { return new Promise((resolve) ...

Setting up Webpack for my typescript React project using Webpack Version 4.39.2

I have been given the task of fixing the Webpack build in a project that I am currently working on. Despite not being an expert in Webpack, I am facing difficulties trying to make it work. The project has an unconventional react frontend with typescript. I ...

Is there a way to access the value stored in a URL parameter if xmlhttp.status shows 500 error?

Hello, I am new to programming and currently working with Javascript and PHP. I have a page that contains several buttons, each of which should link to their respective vendordetails.html page. Once on the vendordetails.html page, a PHP code will be execut ...

What is the best way to dismiss the modal window in React upon clicking the "Add product" button?

Hello all, I'm having trouble figuring out how to close the modal window in React. I want it so that when the user clicks on the "Add" button, a modal window opens for data input, and then upon clicking the "Add product" button, the window closes imme ...

Incorporate additional features from another directory into an object within the current folder

My goal is to develop a system that can import functions from another directory and represent them as objects. The structure I envision is as follows: class = { functions: { //All functions here } } Although the functions will be stored in a separ ...

Troubleshooting issues with the delete functionality in a NodeJS CRUD API

I've been struggling to implement the Delete functionality in my nodejs CRUD API for the past couple of days, but I just can't seem to get it right. As I'm still learning, there might be a small detail that I'm overlooking causing this ...

Implement filtering for schema-less JSON objects within GraphQL

I am facing a challenge with a data JSON object that contains dynamic fields, making it impossible to define the schema in GraphQL. Instead, I defined it as Json using scalar. My goal is to filter the fields within the data JSON object. Here is an example ...

Utilizing JSONP callbacks in Dart

I've been struggling with implementing basic JSONP in Dart and I can't seem to figure it out. After reading this specific blog post along with another helpful resource, it suggests using window.on.message.add(dataReceived); to receive a MessageEv ...

The value passed to the JavaScript function appears to be null, despite not actually being null

Here are the specific API functions I am using to call from JavaScript: function SuspendActionOp(barcode, owner) { //alert(barcode+" - "+num); alert(owner); if (owner == null) { alert('owner is null'); } else { $.ajax({ url: &apo ...

Tips for directing specific mouse interactions to the underlying elements within an SVG

I'm working with a scatterplot that includes a brush layer for zooming in on the data and voronois for mouse hover snapping. However, I've encountered an issue where the click event doesn't fall through to the brush layer when the voronoi pa ...

Displaying placeholder text instead of actual input value

I need help figuring out how to make the input field display the placeholder text instead of the initial value from state. const initialState = [ { name: "Chris", age: 0, height: 0, weight: 0, }, ]; const [inf ...

Best location to structure data within a Ruby on Rails application

I am currently developing a Rails application that will generate a set of measurements collected over several days. Each measurement is saved as an individual record with a timestamp and a value, along with additional metadata. When I request the data (wi ...

Leveraging jquery datatable for displaying JSON data

Here is the JSON output I have: [{"param1":"value1","param2":"value2","param3":"value3"},{"param1":"value1","param2":"value2","param3":"value3"}] I have coded my AJAX request within a function that can be triggered by a button click: function callAjaxRe ...

HTML code displaying a fixed message at the top of the webpage

I'm working on a web page that has a lot of content. I need to have a message always visible at the bottom of the browser window, even when scrolling. Can anyone help me achieve this using simple CSS, HTML, jQuery, or PHP? Thanks! ...

"Enhance your web development skills by mastering jQuery alongside the

It's curious that jQuery doesn't support the use of the "+" sign. You can see how it functions with "1" and "3", but not with "2+". Just hover your mouse over each div to experience it. <div id="div-2+"></div> JSFiddle $('a. ...

Tips for Modifying CSS Design for Unhovered Elements

HTML <ul id="menu"> <li><a href="#">Home</a></li> <li><a href="#">Categories</a> <ul> <li><a href="#">1</a></li> < ...

Passing extra data along with dynamic routes in Reactjs

I'm currently working with Reactjs and Next.js, and I've got my [slug.js] functioning properly with the following URL: <Link href={`/${post.slug}`}><a> However, I need to pass a "hidden" additional parameter along with it. Whenever I ...

How can you use ui.router to set up one controller as the child of another controller?

To create a nested controller in html, you can simply write the child controller inside the parent controller like this: <div ng-controller="parentCtrl"> <div ng-controller="childCtrl"> When using ui.router, you can specify one state as a c ...

Issue with data updating in Angular rxjs with share, map, and filter functions

After gathering search criteria from a form, I have developed a method that retrieves an observable of talents. fetchTalents(searchCriteria) { return this._allUsers$.pipe( tap((talents) => console.log(talents)), map((tale ...

Change the positioning of the image to a new column within the bootstrap grid when a

My website utilizes Bootstrap 4, featuring a <container> with two individual columns. For screen sizes within the Bootstrap 4 breakpoints of md-xl, these columns are displayed side by side with equal widths: col-md-6. On smaller screens like sm-xs, ...