Module: Kvom::Lib::JsonValue
- Defined in:
- lib/kvom/lib/json_value.rb
Class Method Summary collapse
-
.dump(primitive) ⇒ Object
all special cases are just a shortcut.
- .load(jsonvalue_string) ⇒ Object
Class Method Details
.dump(primitive) ⇒ Object
all special cases are just a shortcut
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kvom/lib/json_value.rb', line 10 def dump(primitive) case primitive when nil "null" when true, false primitive.to_s when "" '""' else MultiJson.dump([primitive])[1..-2] end end |
.load(jsonvalue_string) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kvom/lib/json_value.rb', line 23 def load(jsonvalue_string) case jsonvalue_string when "null" nil when "true" true when "false" false when '""' "" else MultiJson.load("[#{jsonvalue_string}]").first end end |