Class: Rets::Metadata::JsonSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/rets/metadata/json_serializer.rb

Overview

Serialize/Deserialize metadata using JSON.

Instance Method Summary collapse

Instance Method Details

#load(file) ⇒ Object

Deserialize from a file. If the metadata cannot be deserialized, return nil.



18
19
20
21
22
# File 'lib/rets/metadata/json_serializer.rb', line 18

def load(file)
  JSON.load(file)
rescue JSON::ParserError
  nil
end

#save(file, o) ⇒ Object

Serialize to a file. The library reserves the right to change the type or contents of o, so don’t depend on it being anything in particular.



12
13
14
# File 'lib/rets/metadata/json_serializer.rb', line 12

def save(file, o)
  file.write o.to_json
end