Skip to content

using SwiftyJSON.subscript in assignment with an empty path does nothing #580

@GilGS

Description

@GilGS

writing the following code will show the bug - the first 3 prints just print the json itself and its attributes. after that, the line "json[emptySubscript] = JSON(7)" should put 7 alone in the json, but when printing the json again it hasn't changed at all.

import SwiftyJSON

var json = JSON(["number": JSON(123),
"code": JSON(456)])

let emptyArray: [String] = []
let emptySubscript = emptyArray.map { $0 as JSONSubscriptType}

print(json.description)
print(json["number"].description)
print(json[emptySubscript].description)

json[emptySubscript] = JSON(7)
print("json after change:\n (json.description)")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions