0.0.29 • Published 9 years ago

jsonconst v0.0.29

Weekly downloads
91
License
-
Repository
github
Last release
9 years ago

jsonconst

This package provides a Javascript library that you can call from your own code

const file = require("file");
function compile_config()
{
    var json = file.read("foo.json");
    var ts = jsonconst.generate(json, "typescript", null, null);
    file.write("foo.ts", ts);
}

###JSON schema Jsonconst allows you to specify the JSON schema for your JSON file:

{
   $schema: "./myschema.schema.json",
   'firstname': "John"
}

Doing so has a number of advantages, as listed below.

####Catching type errors Without a schema, any field can take any value:

{
   'numericValue': "foo",
   'stringValue': 41
}

With a schema, mistakes like the above are caught during compilation:

{
   $schema: "./myConfig.schema.json",
   'numericValue': "foo",
   'stringValue': 41
}

And if your editor supports JSON schemas, you will get error feedback when editing:

FIG

####Intellisense JSON schemas allow you to add descriptions to fields - and if your editor supports it, these descriptions willl be displayed:

FIG

The descriptions will also be passed on to code generation:

0.0.29

9 years ago

0.0.28

9 years ago

0.0.27

9 years ago

0.0.26

9 years ago

0.0.25

9 years ago

0.0.24

9 years ago

0.0.23

9 years ago

0.0.22

9 years ago

0.0.21

10 years ago

0.0.20

10 years ago

0.0.19

10 years ago

0.0.18

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago