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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:19:34+00:00 2026-06-09T21:19:34+00:00

I have json data which contain the whole database record now i need to

  • 0

I have json data which contain the whole database record now i need to perform group by on this return json data with sorting on particular category.

I think sorting is easy to do on json data but i am not sure how i can go with group by. I need to group by on particular set of data.

Any help/suggestion would be great help.

Thanks
ravi

  • 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-09T21:19:36+00:00Added an answer on June 9, 2026 at 9:19 pm
    var obj = [{ "session":"1","page":"a"},
           { "session":"1","page":"b"},
           { "session":"1","page":"c"},
           { "session":"2","page":"d"},
           { "session":"2","page":"f"},
           { "session":"3","page":"a"}];
    
    function GroupBy(myjson,attr){
        var sum ={};
    
        myjson.forEach( function(obj){
           if ( typeof sum[obj[attr]] == 'undefined') {
             sum[obj[attr]] = 1;
           }
           else {
             sum[obj[attr]]++;
           } 
        });
        return sum;
    }
    
    var result = GroupBy(obj,"page");
    
    console.log("GroupBy:"+ JSON.stringify(result));
    ///  GroupBy(obj,"session")  --> GroupBy:{"1":3,"2":2,"3":1}
    ///  GroupBy(obj,"page")  --> GroupBy:{"a":2,"b":1,"c":1,"d":1,"f":1}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a REST api which dumps some json data (user info, etc). Now
I am getting JSON string from website. I have data which looks like this
I have a JSON-like data structure (which I don't want to change) that is
I have 5 view which have deferent json data , in all my 5
I have a JSON data store used for a combobox selection which is working
I have a manager class, which update json data from web, get values... The
I have variable which I populate from JSON formated data. Something like: var time=my_data[data.results[i].id].time;
I have an application which obtains data in JSON format from one of our
I have a flash file which loads data from JSON and parses it. It
I have PHP code which connects to MySql and encodes data to JSON. Later

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.