godotengine / godotengine/godot

In Godot 4.4 dev 2, typed dictionaries not compatible with JSON.parse_string

Open
#97,137 9 comments 1 reaction 0 assignees View on GitHub
discussion documentation topic:core
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

-Reproducible in Godot 4.4 dev 2

### System information

Windows 10, Godot 4.4 dev 2, Forward+

### Issue description

(I'm sorry if there is an open issue about this case and I didn't find it before opening this issue)

When using JSON.parse_string as an assignment to a typed dictionary that is not declared as `Dictionary[Variant, Variant]` (Example from my use case: `Dictionary[String, Dictionary]`) I get the error:

> Invalid assignment of property or key with value of type 'Dictionary'

### Steps to reproduce

- Add a new script to a node
- Add the following script:
```
extends Node

var d : Dictionary[String, Variant] = {}

var s : String = '{"A": "Hi","B": "Hey"}'
"""

func _ready() -> void:
d = JSON.parse_string(s)
```

- Run the script (I got an error)
- Modify the dictionary to be `Dictionary[Variant, Variant]`
- Run the code again (Worked for me)

There is a MRP that has this script, with an extra line (commented by default) that loads the data from a .json file

### Minimal reproduction project (MRP)

[MRP.zip](https://github.com/user-attachments/files/17039753/MRP.zip)

Contributor guide

Open the contributing guide

Research direction

Start by running the attached MRP with the provided script in Godot 4.4 dev 2, comparing the typed dictionary declarations that fail and succeed. Trace JSON.parse_string's returned value and typed-dictionary assignment behavior in the Godot engine. Done means the reported typed assignment behaves consistently with the supported dictionary type expectations and the reproduction no longer errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
godot
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.