Json Extensions
Save String
This saves a string as a JSON file, encrypting it with the provided key.
string text = "Hello, World!";
string path = Application.persistentDataPath;
string fileName = "exampleString";
JsonExtensions.SaveString(text, path, fileName, "encryptionKey");Load String
This loads a JSON file, decrypts its content, and converts it back to a string.
string path = Application.persistentDataPath;
string fileName = "exampleString";
string getText = JsonExtensions.LoadString(fileName, path, "encryptionKey");Save Object
This saves an object (like player data) to a JSON file and encrypts it.
[System.Serializable]
public class PlayerData
{
public string Name;
public int Score;
}
PlayerData player = new PlayerData {
Name = "Alice",
Score = 100
};
string path = Application.persistentDataPath;
string fileName = "playerData";
JsonExtensions.SaveObject(player, path, fileName, "encryptionKey");Load Object
This loads and decrypts a JSON file, converting it back into an object.
Save List
This saves a list of integers to a JSON file with EncryptExtensions.
Load List
This loads a JSON file, decrypts it, and converts it back into a list.
Save Dictionary
This saves a dictionary of player scores to a JSON file with EncryptExtensions.
Load Dictionary
This loads and decrypts a JSON file, converting it back into a dictionary.
Last updated