There doesn't seem to be a mechanism to create an empty dictionary object? Since [] in swift can be interpreted as an empty array or empty object. And,
var json:JSON = JSON([])
creates an empty array, so you can't add properties.
E.g., This would seem to be appropriate, but doesn't work
var json:JSON = JSON()
json["id"].intValue = 123
println(json)
{
"id": 123
}
In Swift, [:] represents an empty dictionary, but SwiftyJSON doesn't have an dictionary-based initializer yet. This should be quite easy to add.
Just checked it: var json:JSON = [:] works, because JSON implements the DictionaryLiteralConvertible protocol.
I think this issue can be closed.
Most helpful comment
Just checked it:
var json:JSON = [:]works, becauseJSONimplements theDictionaryLiteralConvertibleprotocol.