Skip to content

Deserialization aliases objects with the same shape #3828

@SilverEzhik

Description

@SilverEzhik
> local data = hs.json.decode('{"props":{},"children":{}}');  
> print(data.props == data.children)
true
> local data = hs.json.decode('{"props":{"a": 1},"children":{"a": 1}}');  
> print(data.props == data.children)
true

This seems really weird - this means that any two objects with an identical shape will be aliased to one another, causing weird and unpredictable behavior. I've noticed that so far this affects both hs.json and hs.settings.

As a workaround, I've been using https://github.com/rxi/json.lua instead - it can be assigned to hs.json and provides the same interface.

I'm using Hammerspoon 1.0.0 and macOS Tahoe 26.0.1 (25A362).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions