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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:55:19+00:00 2026-06-14T14:55:19+00:00

So I’m trying to display via a template some data from a JSON request.

  • 0

So I’m trying to display via a template some data from a JSON request. The data has some nested objects (of varying amounts) similar to this:

data: "Some data",
nested: [
 {
  nested_data: "foo",
  bar: "foobar"
  }, ...
],
...

I’ve managed to parse the JSON fine and store it in a WinJS.Binding.List object, and bound the result to a template. The problem I’ve got is actually displaying the nested JSON data in my template. The template looks something like this:

<div class="appTemplate">
 <div class="innerTemplate">
  <h1 data-win-bind="innerText: data">
  <h2 data-win-bind="innerText: nested">
 </div>
</div>

When I run the program those, the ‘nested’ part of the template is just a bunch of [object Object] rather than the data I want to display.

Is there some way I can create the template such that it can handle the nested data? Would it be easier to define a template function? Not sure what to do here…

  • 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-14T14:55:20+00:00Added an answer on June 14, 2026 at 2:55 pm

    There is no built in way to do this — the only built in control for iterating over data is the List View. However, you cannot nest List Views.

    There are two ways to solve this problem, depending on your desired outcome:

    1) Stringifying the nested data: You can do this by writing a WinJS.Binding.converter that will convert your array of data into a single string value. Example

    Code:

    WinJS.Namespace.define("Examples.Converters", {
        nestedDataConverter: WinJS.Binding.converter(function(input) {
            // Assume input is array
            var result = "";
            input.forEach(function(data) {
                result += data.nested_data + ", " + bar + ";";
            });
    
            result result;
        }),
    });
    

    Template:

    My recommended solution would to build your own control that will take your array (or WinJS.Binding.List) and create the elements / layouts needed. I have done this in a project I work on, and it’s super simple.

    Example Template:

    <div class="appTemplate" data-win-control="WinJS.Binding.Template">
      <div class="innerTemplate">
        <h1 data-win-bind="innerText: data">
        <h2 data-win-bind="innerText: nested Examples.Converters.nestedDataConverter">
      </div>
    </div>
    

    Now, the h2 will have the single-string version of that data.

    2) Create a control to display the data richly: To do this you need to create a new WinJS control and use it in your template.

    Control example:

    WinJS.Namespace.define("Examples.Controls", {
        Stamper: WinJS.Class.define(function(element, options) {
            WinJS.UI.setOptions(this, options);
            this.domElement = element;
        }, {
            domElement: nullm
            _data: null,
            data: {
                set: function(val) {
                    this._data = val;
                    updateLayout();
                }
            },
            updateLayout: function() {
                this.domElement.innerHTML = "";
                if(!this._data) {
                    return;
                }
    
                this._data.forEach(function(item) {
                    var el = document.createElement("div");
                    el.textContent = "Data: " + item.nested_data + ", " + item.bar;
                    this.domElement.appendChild(el);
                }.bind(this));
            }
        }),
    });
    

    Template:

    <div class="appTemplate" data-win-control="WinJS.Binding.Template">
      <div class="innerTemplate">
        <h1 data-win-bind="innerText: data"></h1>
        <div data-win-control="Examples.Controls.Stamper"
             data-win-bind="winControl.data: nested"></div>
      </div>
    </div>
    

    This control can be extended to render nested templates, and other items. It’s all a question of how complex you want to get.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.