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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
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.