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

The Archive Base Latest Questions

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

I use a json object to handle my menus and breadcrumbs. Now below you

  • 0

I use a json object to handle my menus and breadcrumbs. Now below you can see that the first two “Navigation” nodes are observable, but the last one isn’t. It is just a regular array for some reason. Does the mapping plugin not deep clone the object?

Firebug output:

app.viewModel.members.layout().Navigation()[2].Navigation()[1].Navigation() <-- errors

Initialization:

app.viewModel.members.layout(ko.mapping.fromJS(json.Layout));

json.Layout JSON:

{
  "Layout": {
    "Navigation": [
      {
        "ID": "Dashboard",
        "Type": "Menu",
        "Route": "dashboard",
        "Title": "Dashboard"
      },
      {
        "ID": "Events",
        "Type": "Menu",
        "Route": "events",
        "Title": "Events",
        "Navigation": [
          {
            "ID": "AddEvent",
            "Type": "Action",
            "Route": "events/event",
            "Title": "Add Event",
            "Label": "+ Add Event",
            "Order": "1"
          },
          {
            "ID": "EditEvent",
            "Type": "Item",
            "Route": "events/event",
            "Parameters": "eventid",
            "Title": "Edit Event",
            "Navigation": [
              {
                "ID": "EventGymCourts",
                "Type": "Menu",
                "Route": "events/event/gymcourts",
                "Title": "Locations",
                "Parameters": "eventid",
                "Navigation": [
                  {
                    "ID": "AddEventGymCourt",
                    "Type": "Action",
                    "Route": "events/event/gymcourts/gymcourt",
                    "Title": "Add Location",
                    "Parameters": "eventid",
                    "Label": "+ Add Location",
                    "Order": "1"
                  },
                  {
                    "ID": "EditEventGymCourt",
                    "Type": "Item",
                    "Route": "events/event/gymcourts/gymcourt",
                    "Parameters": "eventid,gymcourtid",
                    "Title": "Edit Location"
                  }
                ]
              },
              {
                "ID": "Teams",
                "Type": "Menu",
                "Route": "events/event/teams",
                "Title": "Teams",
                "Parameters": "eventid",
                "Navigation": [
                  {
                    "ID": "AddTeam",
                    "Type": "Action",
                    "Route": "events/event/teams/team",
                    "Title": "Add Team",
                    "Parameters": "eventid",
                    "Label": "+ Add Team",
                    "Order": "1"
                  },
                  {
                    "ID": "EditTeam",
                    "Type": "Item",
                    "Route": "events/event/teams/team",
                    "Parameters": "eventid,teamid",
                    "Title": "Edit Team"
                  }
                ]
              },
              {
                "ID": "Pools",
                "Type": "Menu",
                "Route": "events/event/pools",
                "Title": "Pools",
                "Parameters": "eventid",
                "Navigation": [
                  {
                    "ID": "AddPool",
                    "Type": "Action",
                    "Route": "events/event/pools/pool",
                    "Title": "Add Pool",
                    "Parameters": "eventid",
                    "Label": "+ Add Pool",
                    "Order": "1"
                  },
                  {
                    "ID": "EditPool",
                    "Type": "Item",
                    "Route": "events/event/pools/pool",
                    "Parameters": "eventid,poolid",
                    "Title": "Edit Pool"
                  }
                ]
              },
              {
                "ID": "Brackets",
                "Type": "Menu",
                "Route": "events/event/brackets",
                "Title": "Brackets",
                "Parameters": "eventid",
                "Navigation": [
                  {
                    "ID": "AddBracket",
                    "Type": "Action",
                    "Route": "events/event/brackets/bracket",
                    "Title": "Add Bracket",
                    "Parameters": "eventid",
                    "Label": "+ Add Bracket",
                    "Order": "1"
                  },
                  {
                    "ID": "EditBracket",
                    "Type": "Item",
                    "Route": "events/event/brackets/bracket",
                    "Parameters": "eventid,bracketid",
                    "Title": "Edit Bracket"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "ID": "Gyms",
        "Type": "Menu",
        "Route": "gyms",
        "Title": "Locations",
        "Navigation": [
          {
            "ID": "AddGym",
            "Type": "Action",
            "Route": "gyms/gym",
            "Title": "Add Location",
            "Label": "+ Add Gym",
            "Order": "1"
          },
          {
            "ID": "EditGym",
            "Type": "Item",
            "Route": "gyms/gym",
            "Parameters": "gymid",
            "Title": "Edit Location",
            "Navigation": {
              "ID": "EditMap",
              "Type": "Menu",
              "Route": "gyms/gym/map",
              "Parameters": "gymid",
              "Title": "Map"
            }
          }
        ]
      }
    ]
  }
}

Update:

Looking closer it looks like since that “Navigation” has only one node, it makes it one object and not an array like the others. How could I remedy this? Using create in the mapping plugin?

  • 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-25T19:59:42+00:00Added an answer on May 25, 2026 at 7:59 pm

    Well I used the create method in the mapping plugin.

    var mapping = {
                            'Navigation': {
                                create: function (options) {
    
    
                                    if (options.data.Navigation) {
                                        if (options.data.Navigation instanceof Array) {
                                            options.data = ko.mapping.fromJS(options.data, mapping);
                                        }
                                        else{
                                            options.data.Navigation = [options.data.Navigation];
                                        }
                                    }
    
                                    return ko.mapping.fromJS(options.data);
                                }
                            }
                        };
    
                        app.viewModel.members.layout(ko.mapping.fromJS(json.Layout, mapping));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started to use Json.NET to convert a string in JSON format to object
Why should I use JSON with ASP.NET? Can you give a practical example? I
how can i convert a string which is a json object to dynamic in
I understand if I use springMVC and pass a json object to the controller,
I have a RESTful WCF service that can return XML, JSON, or JSONP, depending
I can't figure out whether or not to use XML, YAML, or JSON for
i'm trying to use json_decode to combine a few json objects and then re-encode
I know how to use JSON to create objects, but there doesn't seem to
I use an asp (classic) utility file to create json objects from an SQL
I need a tool which generates random JSON objects. I want to use this

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.