Skip to content

angular service to convert a hierarchical nested data structure into a table like representation with selected attributes

License

Notifications You must be signed in to change notification settings

danielsu/ds-angular-nested-json-to-table

Repository files navigation

Build Status

ds-angular-nested-json-to-table

An angular service to convert a hierarchical nested data structure into a table like representation with selected attributes

setup

npm install --save ds-angular-nested-json-to-table

or

bower install --save ds-angular-nested-json-to-table

demo

Take a look at the Video Demo on YouTube

or inspect the simple demo app in 'demo' directory

or see the images below

Example Data: Array of shopping with nested articles lists

nested_data

Workflow Step 1: enter URL and load data

workflow_1_load_data

Workflow Step 2: select properties, that should be used for transformation, 1 nested set allowed

workflow_2_select_properties

Workflow Step 3: generate the final result. Each nested data sets is at top level including selected 'parent' properties.

workflow_3_transformed_result

usage

// parse to get metadata

var metadata = nestedJsonToTableService.getMetaDataFromJson(nestedJson);

var selectedProperties = [ "purchaseDate", "zipCode", "city", "articles.name", "articles.pricePerPiece", "articles.category", "articles.amount" ];

// convert nested 3D structure to relational table like representation, will be stored in service

nestedJsonToTableService.transformNestedDataToORM(nestedJson);

// get transformed tables

var resultArray = nestedJsonToTableService.getItemsWithSelectedProperties(selectedProperties);

See test-cases for details.

test

run npm test

known issues

  • only can generate result table with single nested set selected. fails, if multiple different nested sets are selected (no Cartesian grid)
  • currently synchronous, promises/async to come
  • only basic error handling
  • tests currently in NPM only, due to dependencies with testrunners, which are not available at bower

About

angular service to convert a hierarchical nested data structure into a table like representation with selected attributes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •