mercredi 29 novembre 2017

Nesting more than one JSON - is it the best option for data grid and tables? If yes, how to do it?

I have a database that I will query to calculate some time series (about 150 of them) - they are all financial statements calculated from a general ledger.

I'm writing a code that iterates through the list of accounts (chart of accounts in the financial language) and queries them all.

The result of that code is several JSON objects like:

Account 1:

[
{
    "Y": 2015,
    "ValorTotal": 328.0,
    "M": 4
},

Account 2:

[
{
    "Y": 2015,
    "ValorTotal": 493.0,
    "M": 4
},

Given my objective is to display the information on a datagrid/table (something like the Ember Financial Table) in which the time element is in the columns, and "Accounts" are rows - probably to feed a JQuery plug-in, Bootstrap table or something like that, I ask:

  • Should I work with several JSON or one single JSON?
  • Any other data structure I should look at?

In case the nested JSON is the best option, how could I transform the N objects (showed above) to the nested object (showed below)?

{
    "Y": 2015,
    "M": 4,
    "Accounts": {
        "Account1" : 328,
        "Account2" : 493,
        "Account3" : 574,




Aucun commentaire:

Enregistrer un commentaire