0
0
Unityframework~5 mins

JSON serialization in Unity - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is JSON serialization in Unity?
JSON serialization is the process of converting Unity objects or data into a JSON string format that can be saved or sent, and later converted back to objects.
Click to reveal answer
beginner
Which Unity class is commonly used for JSON serialization?
Unity uses the JsonUtility class to convert objects to JSON strings and back.
Click to reveal answer
beginner
How do you convert an object to a JSON string in Unity?
Use JsonUtility.ToJson(yourObject) to get a JSON string representing your object.
Click to reveal answer
beginner
How do you convert a JSON string back to an object in Unity?
Use JsonUtility.FromJson<T>(jsonString) where T is the type of the object you want to create.
Click to reveal answer
intermediate
What is a limitation of Unity's JsonUtility for serialization?
JsonUtility only works with classes or structs marked as serializable and does not support dictionaries or complex types well.
Click to reveal answer
Which method converts an object to a JSON string in Unity?
AJsonUtility.ParseJson()
BJsonUtility.FromJson()
CJsonConvert.SerializeObject()
DJsonUtility.ToJson()
What must a class have to be serialized by JsonUtility in Unity?
AInherit from MonoBehaviour
BBe marked with [Serializable]
CBe a static class
DImplement ISerializable
Which of these is NOT supported well by Unity's JsonUtility?
ADictionaries
BStructs
CSimple classes
DArrays
How do you deserialize a JSON string to an object of type PlayerData?
AJsonUtility.FromJson<PlayerData>(jsonString)
BJsonUtility.ToJson<PlayerData>(jsonString)
CJsonUtility.Deserialize<PlayerData>(jsonString)
DJsonUtility.Parse<PlayerData>(jsonString)
What is the output type of JsonUtility.ToJson()?
AJSON object
Bbyte[]
Cstring
Dobject
Explain how JSON serialization works in Unity using JsonUtility.
Think about converting objects to strings and back.
You got /4 concepts.
    What are some limitations of Unity's JsonUtility for JSON serialization?
    Consider what data structures JsonUtility cannot handle well.
    You got /4 concepts.