static public JsonOperationResult ExportPartial(UnityEngine.Component targetComp, JsonModifier jsonModifier) { // Conver target object to JSON object // (It can take any System.Object as target) // Conver to JSON string from string cmpJsonStr = JsonUtility.ToJson(targetComp, false); // Convert to JSON object from JSON string SimpleJSON.JSONNode cmpJsonObj = SimpleJSON.JSON.Parse(cmpJsonStr); // Prepare export JSON object from template JSON string string expJsonTemplate = "{\"format\":\"" + jsonFormatName_partialObject + "\", objectType:null, \"hint\":{}, \"data\":{}"; SimpleJSON.JSONNode expJsonObj = SimpleJSON.JSON.Parse(expJsonTemplate); // Add meta info to export JSON object expJsonObj["hint"].Add("PlayerSettings.productName", PlayerSettings.productName); var scene = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene(); expJsonObj["hint"].Add("scene.name", scene.name); expJsonObj["hint"].Add("scene.path", scene.path); expJsonObj["hint"].Add("objectPath", IwsdSubInspectorWindow.GetGameObjectPath(targetComp.gameObject)); expJsonObj["hint"].Add("created", DateTime.UtcNow.ToString("o")); expJsonObj.Add("objectType", targetComp.GetType().FullName); // specify type by full name // Copy partial elements from target JSON object to export JSON object JsonOperationResult r = jsonModifier(cmpJsonObj, expJsonObj); // Convert to portable string (from export JSON object to JSON string) r.Output = expJsonObj.ToString(); return(r); // TODO use EditorJsonUtility }
public static string base64ToJson(string paramBase64) { try { SimpleJSON.JSONNode node = SimpleJSON.JSONNode.LoadFromBase64(paramBase64); return(node.ToString()); } catch (Exception ex) { Debug.LogError(ex.Message); return(paramBase64); } }
static int _m_ToString(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); SimpleJSON.JSONNode gen_to_be_invoked = (SimpleJSON.JSONNode)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 1) { string gen_ret = gen_to_be_invoked.ToString( ); LuaAPI.lua_pushstring(L, gen_ret); return(1); } if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string _aPrefix = LuaAPI.lua_tostring(L, 2); string gen_ret = gen_to_be_invoked.ToString(_aPrefix); LuaAPI.lua_pushstring(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to SimpleJSON.JSONNode.ToString!")); }
public IParseble Parse(SimpleJSON.JSONNode rootNode) { if (rootNode != null && !"null".Equals(rootNode.ToString())) { this._status = rootNode["status"]; this._final = rootNode["final"].AsBool; this._elapsedTime = rootNode["elapsedTime"].AsInt; switch (rootNode["group"]) { case "invoice": { this._group = XsollaStatus.Group.INVOICE; break; } case "done": { this._group = XsollaStatus.Group.DONE; break; } case "delivering": { this._group = XsollaStatus.Group.DELIVERING; break; } case "troubled": { this._group = XsollaStatus.Group.TROUBLED; break; } default: { this._group = XsollaStatus.Group.UNKNOWN; break; } } } return(this); }