gagan-bansal / json-groupby Goto Github PK
View Code? Open in Web Editor NEWGroup json data based on properties of json
License: MIT License
Group json data based on properties of json
License: MIT License
if the propertyy in your json is of type date.
Should the output of groups be an array?
Like explained here:
https://stackoverflow.com/q/23600897/713573
If yes, then there would be major
version bump and need to maintain this version also.
If group by key is not present in the sample then create a separate group by name undefined.
Right now it throws error.
Is the use of debugger
intentional on line 14 or can that be omitted in the master branch?
Convention over configuration.
var group = groupBy(array, properties [, collect])
Right now properties
is an array, I think can be a string in case of single property.
Hi,
Thanks for this package, I using it and liked.
I have a problem with a json here:
[
{
"id_programacao": 1,
"evento": "TESTE PROGRAMACAO 1",
"descricao_evento": "teste usando o NodeJS",
"tipo_evento": "Palestra",
"local": "PRODAM",
"hora_inicio": "2016-10-10T22:26:15.000Z",
"hora_fim": "2016-10-13T22:26:22.000Z",
"id_palestrante": 2,
"nome": "Bruno Mendes",
"cargo": "Analista",
"empresa": "PRODAM",
"curriculum": "Tem muito que aprender ainda... ¬¬"
},
{
"id_programacao": 1,
"evento": "TESTE PROGRAMACAO 1",
"descricao_evento": "teste usando o NodeJS",
"tipo_evento": "Palestra",
"local": "PRODAM",
"hora_inicio": "2016-10-10T22:26:15.000Z",
"hora_fim": "2016-10-13T22:26:22.000Z",
"id_palestrante": 1,
"nome": "Rodolfo Azevedo",
"cargo": "Programador",
"empresa": "PRODAM",
"curriculum": "Esse bixo manja velho"
},
{
"id_programacao": 2,
"evento": "TESTE PROGRAMACAO 2",
"descricao_evento": "teste usando o Java",
"tipo_evento": "Palestra",
"local": "PRODAM",
"hora_inicio": "2016-10-14T22:26:15.000Z",
"hora_fim": "2016-10-15T22:26:22.000Z",
"id_palestrante": 3,
"nome": "Bruno do Mobile",
"cargo": "Programador",
"empresa": "PRODAM",
"curriculum": "Até nos feriados"
}
]
I have id_programacao: 1, but I have two id_palestrantes in this programacao, I like to transform this json to this:
[
{
"id_programacao": 1,
"evento": "TESTE PROGRAMACAO 1",
"descricao_evento": "teste usando o NodeJS",
"tipo_evento": "Palestra",
"local": "PRODAM",
"hora_inicio": "2016-10-10T22:26:15.000Z",
"hora_fim": "2016-10-13T22:26:22.000Z",
palestrantes: [
{
"id_palestrante": 2,
"nome": "Bruno Mendes",
"cargo": "Analista",
"empresa": "PRODAM",
"curriculum": "Tem muito que aprender ainda... ¬¬"
},
{
"id_palestrante": 1,
"nome": "Rodolfo Azevedo",
"cargo": "Programador",
"empresa": "PRODAM",
"curriculum": "Esse bixo manja velho"
}
]
},
{
"id_programacao": 2,
"evento": "TESTE PROGRAMACAO 2",
"descricao_evento": "teste usando o Java",
"tipo_evento": "Palestra",
"local": "PRODAM",
"hora_inicio": "2016-10-14T22:26:15.000Z",
"hora_fim": "2016-10-15T22:26:22.000Z",
"id_palestrante": 3,
"nome": "Bruno do Mobile",
"cargo": "Programador",
"empresa": "PRODAM",
"curriculum": "Até nos feriados"
}
]
Can you help me ?
Thanks and Regards.
This library is very useful and the syntax make it easy to understand (very close to pandas a Python data manipulation library). However I see a missing feature that concern recurring use case .
Given the example of a book store, I retrieve the list of books with their title and the list of their authors.
{
"title": "",
"author": [
{
"given": "",
"family": "",
"affiliation": []
},
{
"given": "",
"family": "",
"affiliation": []
},
]
Then I want to group those books by authors. (This append a lot when you have entities with a relation where books asMany authors.
Your library could implement a SQL like syntax to specify on which property inside the array you want to group
groupBy(books, ['author.given'])
One solution to tackle this would be to add a temporary array tmp
that contain the property given
for each author
then use the group by as for tags
books.forEach(function(item) {
item.tmp = item['authors'].map(function(x) {
return x.['given'];
})
});
groupBy(books, ['tmp'])
I believe this feature will complete the coverage of this library in terms of grouping and manipulating JSON Objects
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.