0

I use jquery tokeninput. A flatted json is no problem to be searched. but howto input nested object.

my code:

   var flat_obj = [{id: 7, name: "Ruby"}, {id: 11, name: "Python"}];
   var nested_obj = [{ "name": "main", "id": "2", "Parent": "0", "children": [{ "name": "submain", "id": "3", "Parent": "2"}] }];

   $("#search-input-local").tokenInput(nested_obj, { });
4
  • jQuery TokenInput doesn't handle nested JSON - you should format the JSON before you pass it to the plugin. What effect are you trying to achieve? Commented Sep 30, 2014 at 22:29
  • Thank u Chris, Is there a function to convert nested to flat object in javascript? Commented Oct 1, 2014 at 4:04
  • What are you trying to achieve, to have every item in the TokenInput list, including the 'children'? Commented Oct 1, 2014 at 8:32
  • Yes, including the 'children'. Commented Oct 1, 2014 at 9:48

1 Answer 1

1

TokenInput doesn't handle nested JSON, you will need to format the JSON correctly before you pass it to the plugin.

There are a number of libraries to flatten JSON, or take a look at this question here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.