Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

json-to-crystal

0.5.8 • Public • Published

JSON to Crystal

Convert JSON structures to Crystal classes. A hosted version is available at https://watzon.me/projects/json-to-crystal.

Usage

const JsonToCrystal = require('json-to-crystal')
 
const json2crystal = new JsonToCrystal()
console.log(json2crystal.parse(`
{
    "string": "Hello world",
    "boolean": true,
    "integer": 12302932,
    "float: 232.23,
    "another_class": {
        "arr": [1, 2, 3],
        "hello": "World!"
    }
}`))
class AutoGenerated

  JSON.mapping({
    string: { type: String },
    boolean: { type: Bool },
    integer: { type: Int32 },
    float: { type: Float64 },
    another_class: { type: AnotherClass }
  })

  class AnotherClass

    JSON.mapping({
      arr: { type: Array(Int32) },
      hello: { type: String }
    })

  end
end

install

npm i json-to-crystal

Downloadsweekly downloads

19

version

0.5.8

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability