Class: KBuilder::Webpack5::JsonData

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/k_builder/webpack5/json_data.rb

Overview

Represents a node in a JSON object

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse_json(json) ⇒ Object



7
8
9
10
# File 'lib/k_builder/webpack5/json_data.rb', line 7

def self.parse_json(json)
  json = json.to_json if json.is_a?(Hash)
  JSON.parse(json, object_class: JsonData)
end

Instance Method Details

#as_jsonObject



12
13
14
# File 'lib/k_builder/webpack5/json_data.rb', line 12

def as_json
  KBuilder.data.struct_to_hash(self)
end