Skip to content

FGRibreau/valid-json-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

valid-json-template

yeah, because json-template was taken

Deps Version Downloads Circle CI Slack

Why

Because sometimes you have a template like this that needs to be a valid JSON:

var myTemplate = `{
  "user": {
    "age": "{{ age.computed }}",
    "biography": "{{ biography }}",
    "hasBlueEyes": "{{ eyes.areBlue }}",
  }
}`;

with a dataset like this:

{
  "biography": "Hello world, 42.",
  "age":{
    "computed": 25
  },
  "eyes":{
    "areBlue": true
  }
}

and you want this:

{
  "user": {
    "age": 25,
    "biography": "Hello world, 42.",
    "hasBlueEyes": true
  }
}

npm

npm install valid-json-template -S

About

Use a (valid) JSON as a template that produce another valid JSON as a result

Resources

License

Stars

Watchers

Forks

Packages

No packages published