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
- [iOS] Spikes can be seen in the Profiler when tapping the screen on ProMotion devices
- [Linux] Crash on pthread_kill when using incremental GC
- "Broken text PPtr in file(Assets/GemHunterMatch/Characters/Mermaid/Animations/Controller_PSD_character_mermaid.controller)" is thrown when importing "Gem Hunter Match - 2D Sample Project" into the project
- .wav and .ogg audio files can't be imported to the project when the WebGL Build Profile is selected
- [VFX Graph] Capacity Issue when using GPUEvent and Strips.
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.