Module: RustyJson

Defined in:
lib/rusty_json.rb,
lib/rusty_json/parser.rb,
lib/rusty_json/version.rb,
lib/rusty_json/rust_struct.rb

Overview

RustyJson is a gem to support [Rust](www.rust-lang.org) development when using JSON. For a deeply nested JSON object, one may create many structs to define the syntax of the expected JSON. RustyJson merely Aims to reduce that :)

Defined Under Namespace

Classes: Parser, RustStruct

Constant Summary collapse

VERSION =
"1.2.1"

Class Method Summary collapse

Class Method Details

.parse(json, name = 'JSON') ⇒ Object

Example Usage:

json = File.read('json_file.json') rust = RustyJson.parse(json) File.write('output_structs.rs', rust)

In the above example, RustyJson will parse the JSON in the file: json_file.json and then you print the rust structs out to a Rust File.

Parameters:

  • json (String)

    the name of the returned struct

  • name (String) (defaults to: 'JSON')

    the JSON to parse

Returns:

  • String


25
26
27
28
# File 'lib/rusty_json.rb', line 25

def self.parse(json, name = 'JSON')
  parser = Parser.new(name, json)
  parser.parse
end