Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build namespaces need more options #4

Closed
blakef opened this issue Mar 2, 2016 · 0 comments
Closed

Build namespaces need more options #4

blakef opened this issue Mar 2, 2016 · 0 comments
Assignees

Comments

@blakef
Copy link
Owner

blakef commented Mar 2, 2016

Overview

Currently builds allow namespaces to be built by referencing the namespace as a string argument:

new JSONifier({namespace: 'a'}).add({'b': 'c'}).build('a')
> {'b': 'c'}

Limits

We need more options to allow output to be customised. Namespaces should be used for 2 cases:

  • differentiate between various parts of a composite JSON object (I want to use namespaces to include or exclude inherited JSON),
  • represent actual key values (I want the namespaces included in the output)

Future

  1. Allow: string and object arguments to build:
.build('a')
.build({namespace:'a'}) 
  1. Allow multiple namespaces to be build:
.build({namespace:['a', 'b', 'c']}) 
  1. Allow namespaces to be merged
let a = new JSONifier({namespace: 'a'})
   .add({'a': '1'})
   .add({'b': '2'});
let b = new JSONifier({namespace: 'b'})
   .add({'b': 'woot'});

b.build('a').next().value
> {'a': '1', 'b': '2'}
b.build({namespace: 'a'}).next().value
> {'a': '1', 'b': '2'}

b.build('b').next().value
> {'b': 'woot'}

b.build().next().value
> {'a': {'a': '1', 'b': '2'}, 'b': {'b': 'woot'}}

b.build({nest: false}).next().value
> {'a': '1', 'b': 'woot'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant