Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6537995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:41:00+00:00 2026-05-25T10:41:00+00:00

In the context of a web app, I have a server which sends or

  • 0

In the context of a web app, I have a server which sends or receives JSON strings based on the input from the client. On client consumption, these JSON strings are immediately converted into JavaScript objects where they will live out their lives as objects. These objects are not arrays; they represent complex, arbitrary data models, each property of which can have an arbitrary number of unique subproperties or objects.

var myView = {
    name: 'root'
    id: 'root_0'
    children: {
       child_1: {
          arbitraryid: 'root_0_child_1',
          type: 'Department',
          name: 'Produce',
          quadrant: 1,
          children: {
              child_1: {
                  arbitraryid: 'root_0_child_1_child_1',
                  type: 'Aisle',
                  number: 3,
                  length: 12,
                  children: { }
              }
          }
       },
       child_2: {
          arbitraryid: 'root_0_child_2',
          name: 'West',
          type: 'Region',
          children: {
              child_1: {
                  arbitraryid: 'root_0_child_2_child_1',
                  name: 'Wegmans',
                  type: 'Store', 
                  children: { 
                      child_1: {
                          arbitraryid: 'root_0_child_2_child_1_child_1',
                          type: 'Department',
                          children: { }
                      }
                  }
             }
          }      
       }
    }
};

When I build the JSON string server side, I guarantee that all objects will have ‘children’ and ‘arbitraryid’ properties; but everything else is dynamically generated and the properties and values are completely arbitrary.

If this were XML, I could use jQuery to var someChild = myView.find('#root_0_child_1_child_1'). This would get me a jQuery object with the results of the find AND not only a reference to myView but a position from which to move omnidirectionally through the object: var someChild = myView.find('#root_0_child_1_child_1').parent().

Does a utility exist to solve this problem for native, JavaScript objects or is there a preferable way/methodology to do this? I’d like to avoid writing a bunch of this type of code to simply get at my property and then potentially loop again to update the parent object.

while (obj.hasOwnProperty('children')) {
   for (var child in obj) {
     //..etc, etc
   } 
}

Most of the SO questions I see on this subject deal with searching arrays, frequently with predictable data table style construction.

Mapping is possible, but these objects quickly become deep and that option seems little better than dumb looping.

Ideas?

Edit: rolling my own utility class.

I’m still exploring other libraries/utilities, but I wrote a generic helper class to do searches:

ObjectHelper

While useful, I think it illustrates some of the difficulty with getting at other jQuery-like functionality. Not only would I like to search, but I’d like to be able to crawl up/down the object property structure similarly to the way you can chain .parent().children().find() operators together. Doable, but complicated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:41:00+00:00Added an answer on May 25, 2026 at 10:41 am

    I solved this by rolling my own classes. ShadesJS is pretty basic right now, but it has some methods for crawling JavaScript objects and working with Web Storage. On the to-do is implement parent/child methods to get some JQuery-esque flexibility. It’s not hard to do, but it’s tricky to get it right and performant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net web app which holds its data in an sql server
I'm thinking about adding another static server to a web app, so I'd have
I have a web server based on paste.httpserver as an adapater between HTTP and
I have a web app where people can create custom content on the web
I have a reviews/ratings web application, a la Digg. My django app content has
I need the context to ApplicationContext.xml ,which I provided in web.xml as <listener> <listener-class>
I have a web app where users can follow one another. When one user
I've set up a simple Eclipse 3.5/Jetty 6.1 web app which returns hello world.
I am developing an app for android mobiles that communicates with a json/rest web
I come from a web background where I only have to deal with HTTP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.