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 8837789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:49:03+00:00 2026-06-14T09:49:03+00:00

I have structured data, with various types of data in it. For the sake

  • 0

I have structured data, with various types of data in it. For the sake of simplicity, let’s say I have something like this:

{
  person : [
    { 
      name : 'paul',
      title : 'prof',
      profession : 'teacher',
      start: '2010-10-10'
    },
    { 
      name : 'joe',
      title : 'dr',
      profession : 'scientist',
      start: '2000-01-01'
    }
  ]
  book : [
    {
       title : 'the cat in the hat'
    }
  ] 
}

I would like to have an autocomplete box in javascript that lets me choose the names of these structured elements so the following results would be returned given the letter typed:

't' : {'person.title', 'book.title'}
'p' : {'person', 'person.profession'}

What is important to me is that the person might know the name of any of the variables within the tree. So if they type in the name of the top level variable, I only want to show that one and none of it’s sub-elements, but if they type in the name of sub-element, I want the full path to that sub-element displayed. If they type in a top-level variable (“person”), I don’t want to display all the sub-elements, only ones that always begin with that same set of letters.

Are there any libraries out there that can currently do this (provide a way of doing auto-complete on structured data) as opposed to normal auto-complete?

Clarification: I guess what I need is the ability to tell the auto-complete library a map of inputs and outputs to work with, such that typing “p” will end up hitting on the inputs “person” and “profession” and thus return “person” and “person.profession”, and typing “t” hits on “title” for “person.title” and “title” for “book.title”.

  • 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-06-14T09:49:04+00:00Added an answer on June 14, 2026 at 9:49 am

    Just wrote a function that recurses over an object to retrieve the fullpath property names as an array e.g. person.title. The array can then be used with jQueryUI autocomplete functionality. Please look at the fiddle to confirm this is what you wanted.

    Fiddle here

    var retrieveUniqueProps = ( function ( ) {
    
        var result = [];
        var added = {};
    
        isArray = function( o ) { 
            return Object.prototype.toString.call( o ) === "[object Array]";
        };
    
        isObject = function( o ) { return typeof o === "object"; };
    
        return function ( obj, parentPath ) {
    
            if( isArray( obj ) ) {
    
                for( var i = 0; i < obj.length; i++ ) {
    
                    if( isArray( obj[i] ) || isObject( obj[i] ) ){ 
                        retrieveUniqueProps( obj[i], parentPath ); 
                    }
                }
    
            } else if ( isObject( obj ) ) {
    
                for( var a in obj ) {
    
                    if( obj.hasOwnProperty( a ) ) {
    
                        var fullpath = parentPath ? parentPath + "." + a : a;
                        if( !added[ fullpath ] ) {
                            result.push( fullpath );
                            added[ fullpath ] = true;
                        }
    
                        if( isArray( obj[a] ) || isObject( obj[a] ) ){ 
                            retrieveUniqueProps( obj[a], parentPath ? parentPath + "." + a : a ); 
                        }
                    }
                }
            }
    
            return result;
        };
    
    
    }());
    
    var uniquePropertyNames = retrieveUniqueProps( o, "" );
    

    UPDATE
    I have amended the source option of autocomplete to filter out the results as per your requirements. The last word must match what you have typed into the input. Check out the fiddle for the updated version.

     $("#props").autocomplete({
        source: function(request, response) {
    
                    // The term the user searched for;
                    var term = request.term;
    
                    // Extract matching items:
                    var matches = $.grep(uniquePropertyNames, function(item, index) {
                    // Build your regex here:
                    var subArray = item.split( "." );
    
                    if( subArray[subArray.length - 1].indexOf( term ) !== 0 ) return false;
                    return true;
                });
    
                // let autocomplete know the results:
                response(matches);        
            }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a bit confused on this. I have a data table structured like this:
I have a set of data that is structured like this: ItemA.GroupA ItemB.GroupA ItemC.GroupB
I have this array {$man_data} which is structured like 10 > 'Text 8' 14
My table have data structure like this cate_id task_id date_start date_end other 34 14
In Java (Swing), say I've got a 2D game where I have various types
I have a page that looks something like this: ... <div class=container> <div class=info>
Does anyone have a list of rough rule-of-thumb estimators for the various data structures?
I have text files containing structured data (it is a proprietary format and not
I have a restful webservice which receives some structured data which is put straight
I have a dataset of securities prices in a database. The data is structured

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.