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
- Sprite Shape Corners and Edges are invisible when a closed Sprite Shape is used
- Script icon Gizmos cause lag/performance issues in Scene view even when the Scene Camera is not pointed at Gizmos
- Visual artifacts when the normal map is using mipmap and Bilinear filtering or Point filtering in URP Lit shader
- Crash on MonoBehaviour::VirtualRedirectTransfer when closing Editor after removing HDPR and importing Water Samples before
- Scene from a specific project is stuck loading in the Web Player with the "Uncaught (in promise) TypeError" error thrown in the browser console
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.