Search Issue Tracker
Fixed in 2019.2.X
Fixed in 2019.1.X
Votes
1
Found in
2017.1.0f3
Issue ID
942547
Regression
No
JsonUtility.ToJson() modifies its input parameters
To reproduce:
1. Open the project, attached by the user (ToJsonTest.zip)
2. Open Test Runner
3. Run all EditMode tests
4. Observe that ToJson fails, because null was expected
5. (Optional) Observe the ToJsonTest.cs script
Expected: JsonUtility.ToJson doesn't modify its parameter and if a member of a class is null, it serializes it as null
Reproduced in 5.5.4p2, 5.6.3f1, 2017.1.0f3, 2017.1.0p4, 2017.2.0b7, 2017.3.0a4
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Undoing the creation of the "Button - TextMeshPro" GameObject only removes Canvas and EventSystem GameObjects
- NullReferenceException errors are thrown when entering the Play Mode when ShaderGraph window is focused
- A distorted audio clip is played when transitioning to another audio clip using Pitch Shifter Audio Effect
- [Linux] Window location is not saved when reopening windows
- Selecting default reference on script asset causes immediate code compilation
Resolution Note (fix version 2019.2):
The behaviour where ToJson() was causing the null-valued field to no longer be null after the call has been fixed.
However, the output of ToJson() has not been changed - null-valued fields will still have dummy instances written for them in the output. Changing this behaviour now would break things, and would be inconsistent with how Unity serialization works in general. We'll consider the scenario as part of future feature development in the area.