Closed firvorski closed 6 years ago
Hi,
The type returned by json(fromObjects:)
is an array of dictionaries that can be converted to JSON using JSONSerialization
. So you probably want to do this:
let results = json(fromObjects: logs)
let data = try! JSONSerialization.data(withJSONObject: results)
let json = String(data: data, encoding: .utf8)!
print(json)
Great! It's working now. Thanks a lot.
Hi, I wondered if anyone might have a suggestion as to what I might be doing wrong here.
When I try to serialise my core data objects, in the output I get the field names (and some string values too) do not have any quotes around them i.e. do not appear to be strings. If I then try to import a file with JSON data formatted in this way it fails.
All name and id fields are strings. The other objects are integers or binary.
The output