210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
# File 'lib/rdf_objects/parsers.rb', line 210
def self.parse(json)
collection = []
json.each_pair do |subject, assertions|
resource = Resource.new(subject)
collection << resource
assertions.each_pair do |predicate, objects|
objects.each do | object |
if object['type'] == 'literal'
opts = {}
if object['lang']
opts[:language] = object['lang']
end
if object['datatype']
opts[:data_type] = object['datatype']
end
literal = Literal.new(object['value'],opts)
resource.assert(predicate, literal)
elsif object['type'] == 'uri'
o = Resource.new(object['value'])
resource.assert(predicate, o)
collection << o
elsif object['type'] == 'bnode' o = Resource.new(object['value'])
resource.assert(predicate, o)
collection << o
end
end
end
end
collection.uniq
end
|