Method: OpenC3::Model.from_json

Defined in:
lib/openc3/models/model.rb

.from_json(json, scope:) ⇒ Model

Returns Model generated from the passed JSON.

Returns:

  • (Model)

    Model generated from the passed JSON



93
94
95
96
97
98
99
100
# File 'lib/openc3/models/model.rb', line 93

def self.from_json(json, scope:)
  json = JSON.parse(json, :allow_nan => true, :create_additions => true) if String === json
  raise "json data is nil" if json.nil?

  json[:scope] = scope
  json.transform_keys!(&:to_sym)
  self.new(**json, scope: scope)
end