Skip to content

Setting an array to empty not working #800

@AnthonyMDev

Description

@AnthonyMDev

When trying to set an array nested in my JSON to an empty array, nothing is happening.

let json =  JSON(["array": [1, 2, 3]])

json["array"] =  JSON([]) 
json["array"].array = JSON([])
json["array"].arrayObject = []

print(json) // ["array": [1, 2, 3]]

I currently have to do this to get it to properly set the array:

var json =  JSON(["array": [1, 2, 3]])

var dict = json.dictionaryObject
dict["array"] = []
json = JSON(dict)

This error is occurring using version 3.1.4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions