0.0.29 • Published 8 years ago

jsonconst v0.0.29

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

8 years ago

0.0.28

8 years ago

0.0.27

8 years ago

0.0.26

8 years ago

0.0.25

8 years ago

0.0.24

9 years ago

0.0.23

9 years ago

0.0.22

9 years ago

0.0.21

9 years ago

0.0.20

9 years ago

0.0.19

9 years ago

0.0.18

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago