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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:32:25+00:00 2026-06-07T09:32:25+00:00

There is a json(#json) like as follow, in student section, first two one is

  • 0

There is a json(#json) like as follow, in student section, first two one is a group, last two one is a group.(group by a set of no. like no.1 and no.2 are one set).
The problem is i need fetch the data from student section and make 2 table (depend on how many set of no., 2 in this example). How to modify the json data structure programmatically that i can fetch the data to do above thing?

The table(#table1) look like :
no. name
1 tom
2 jacky

no. name
1 tom
2 jacky

#json

{
"people": {
    "student": [{
        "name": "tom"
        "no.": "1"
        "other": "a"
    },{
        "name": "tom"
        "no.": "1"
        "other": "e"
    },{
        "name": "jack"
        "no.": "2"
        "other": "d"
    },{
        "name": "tom"
        "no.": "1"
        "other": "c"
    },{
        "name": "tom"
        "no.": "1"
        "other": "d"
    },{
        "name": "jack"
        "no.": "2"
        "other": "g"
    }]      
}}

here is my jsRender template:

    <table>      
    <thead>
        <tr><td>Table 1</td></tr> 
        <tr><td>no.</td><td>name</td></tr> 
    </thead> 
    <tbody>
    {{for student}}
        <td>{{>no.}}</td>
        <td>{{>name}}</td>
    {{/for}}
    </tbody>
</table>

It will output:

no. name
1 tom
2 jacky
1 tom
2 jacky

How can i modify my template to make the output like #table1

  • 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-07T09:32:27+00:00Added an answer on June 7, 2026 at 9:32 am

    You need something like this:

    var yourJSON; // All JSON data
    var studentData = yourJSON.people.student; // Student array
    var tableIndex = 1; // Index for table name
    
    // Loop to print student data
    for (var i = 0, length = studentData.length; i < length; i++) {
        if (studentData[i]['no.'] == '1') {
            if (tableIndex > 1) {
                print('</tbody></table>');
            }
            print('<table>' +
                '<thead>' +
                    '<tr>' +
                        '<td>Table ' + tableIndex + '</td>' +
                    '</tr>' + 
                    '<tr>' +
                        '<td>no.</td>' +
                        '<td>name</td>' +
                    '</tr>' + 
                '</thead>' +
                '<tbody>');
            tableIndex++;
        }
        print('<tr><td>' + studentData[i]['no.'] + '</td>');
        print('<td>' + studentData[i]['name'] + '</td></tr>');
    }
    
    print('</tbody></table>'); // Closing the last table
    

    I don’t know how your template engine works so I used the print function to show what is needed to be added in the template.

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

Sidebar

Related Questions

I have a generated JSON file that I would like to transform. Is there
I'd like to load images from json data which contains the url to these
i have a json file with many elements like these: { code : hfuiew89,
Is there a JSON query class or jQuery plugin that I can use to
There is simple JSON serialization module with name simplejson which easily serializes Python objects
Are there any Python JSON parsers that will cope with trailing commas? (I'm consuming
I want to use geoJSON-formatted Data in my iPhone app. THere is a JSON
There are a number of JSON libraries available for Erlang, and it's not clear
There are couple of JSON frameworks. JSONKit , SBJSON , Native JSON and other.
There is a way to pretty-print valid JSON with Python : How can 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.