public XCMod(string filename) { FileInfo projectFileInfo = new FileInfo(filename); if (!projectFileInfo.Exists) { Debug.LogWarning("File does not exist."); } name = System.IO.Path.GetFileNameWithoutExtension(filename); path = System.IO.Path.GetDirectoryName(filename); string contents = projectFileInfo.OpenText().ReadToEnd(); _datastore = (Hashtable)XMiniJSON.jsonDecode(contents); // group = (string)_datastore["group"]; // patches = (ArrayList)_datastore["patches"]; // libs = (ArrayList)_datastore["libs"]; // frameworks = (ArrayList)_datastore["frameworks"]; // headerpaths = (ArrayList)_datastore["headerpaths"]; // files = (ArrayList)_datastore["files"]; // folders = (ArrayList)_datastore["folders"]; // excludes = (ArrayList)_datastore["excludes"]; }
/// <summary> /// Converts a Hashtable / ArrayList / Dictionary(string,string) object into a JSON string /// </summary> /// <param name="json">A Hashtable / ArrayList</param> /// <returns>A JSON encoded string, or null if object 'json' is not serializable</returns> public static string jsonEncode(object json) { var builder = new StringBuilder(BUILDER_CAPACITY); var success = XMiniJSON.serializeValue(json, builder); return(success ? builder.ToString() : null); }
/// <summary> /// Parses the string json into a value /// </summary> /// <param name="json">A JSON string.</param> /// <returns>An ArrayList, a Hashtable, a double, a string, null, true, or false</returns> public static object jsonDecode(string json) { // save the string for debug information XMiniJSON.lastDecode = json; if (json != null) { char[] charArray = json.ToCharArray(); int index = 0; bool success = true; object value = XMiniJSON.parseValue(charArray, ref index, ref success); if (success) { XMiniJSON.lastErrorIndex = -1; } else { XMiniJSON.lastErrorIndex = index; } return(value); } else { return(null); } }
public XCMod(string filename) { FileInfo projectFileInfo = new FileInfo(filename); if (!projectFileInfo.Exists) { Debug.LogWarning("File does not exist."); } name = System.IO.Path.GetFileNameWithoutExtension(filename); path = System.IO.Path.GetDirectoryName(filename); string contents = projectFileInfo.OpenText().ReadToEnd(); _datastore = (Hashtable)XMiniJSON.jsonDecode(contents); }