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
- The Scene View becomes gray and "NullReferenceException" errors are thrown when attaching the Unity Editor process to RenderDoc
- Memory usage rapidly rises when changing colors in the color wheel
- Physically Based Sky's Horizon and Zenith Tint Color Selection Bars don't have immediate access to color pickers
- EmptyAdditionalLightShadowmapTexture leaks from memory when URP quality level is changed using QualitySettings.SetQualityLevel
- Referenced ScriptableObject field does not get updated and cannot be set to "None" when there are no Objects of that type
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.