0.0.29 • Published 7 years ago

jsonconst v0.0.29

Weekly downloads
91
License
-
Repository
github
Last release
7 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

7 years ago

0.0.28

7 years ago

0.0.27

7 years ago

0.0.26

7 years ago

0.0.25

7 years ago

0.0.24

7 years ago

0.0.23

7 years ago

0.0.22

7 years ago

0.0.21

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago