Project

bxtjson

0.0
No commit activity in last 3 years
No release in over 3 years
initialize empty hash from schema, map from hash to schema, return a lazy enumerable
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.5.0, ~> 0.5
>= 1.10.0, ~> 1.10
 Project Readme

bxtjson

Map json from source to fit schema structure

The Gist

Sometimes, you have a B.erry X.tra special T.-rex json-schema(.org), but she doesn't even have a skeleton.

Bxtjson.skeleton(schema_data: trex_schema_hash)
#=> {
      your: nil,
      skeleton: [],
      ready: {
        for: nil,
        data: nil
        }
    }

Othertimes your T-rex json-schema is lost in a Pre-historic ForestSchema. For more details on that forest, Read up on the very useful json_schema library.

Bxtjson.skeleton(schema_data: forest_schema_hash, entity: 't-rex')
#> {the: nil, skeleton: [], 'just-for-trex' => nil}

Then, bring him to life with

Bxtjson.muscle(json_filename: 'path/to/trex-data.jsonl', schema_filename: 'path/to/trex-schema.json')
#=> {
      your: 'muscled',
      skeleton: [:super, :strong, :now],
      ready: {
        for: 'action',
        data: 'forest of beasts'
        }
    } # this is lazy, so use `take(10).force` or the like.

That's it. Super short source code with docs, so read-up. You can also save out the data to a model (ActiveRecord; Sequel) that responds to method 'create'

I'm going for functional style code, so you can also use the "methods" in Bxtjson for your own purposes. Very open to contribution, comment, and write me some tests.