static void JsonExportPointF(PointF pt, LitJson.JsonWriter writer) { writer.WriteObjectStart(); writer.WritePropertyName("X"); writer.Write(pt.X); writer.WritePropertyName("Y"); writer.Write(pt.Y); writer.WriteObjectEnd(); }
/// <summary> /// Creates a new anonymous stomt on the specified target with an image attached to it. /// </summary> /// <param name="positive">The stomt type. True for "I like" and false for "I wish".</param> /// <param name="target">The target to post the stomt to.</param> /// <param name="text">The stomt message.</param> /// <param name="image">The image texture to upload and attach to the stomt.</param> public void CreateStomtWithImage(bool positive, string target, string text, Texture2D image) { if (image == null) { CreateStomt(positive, target, text); return; } byte[] imageBytes = image.EncodeToPNG(); if (imageBytes == null) { return; } var jsonImage = new StringBuilder(); var writerImage = new LitJson.JsonWriter(jsonImage); writerImage.WriteObjectStart(); writerImage.WritePropertyName("images"); writerImage.WriteObjectStart(); writerImage.WritePropertyName("stomt"); writerImage.WriteArrayStart(); writerImage.WriteObjectStart(); writerImage.WritePropertyName("data"); writerImage.Write(Convert.ToBase64String(imageBytes)); writerImage.WriteObjectEnd(); writerImage.WriteArrayEnd(); writerImage.WriteObjectEnd(); writerImage.WriteObjectEnd(); var jsonStomt = new StringBuilder(); var writerStomt = new LitJson.JsonWriter(jsonStomt); writerStomt.WriteObjectStart(); writerStomt.WritePropertyName("anonym"); writerStomt.Write(true); writerStomt.WritePropertyName("positive"); writerStomt.Write(positive); writerStomt.WritePropertyName("target_id"); writerStomt.Write(target); writerStomt.WritePropertyName("text"); writerStomt.Write(text); writerStomt.WritePropertyName("img_name"); writerStomt.Write("{img_name}"); writerStomt.WriteObjectEnd(); StartCoroutine(CreateStomtWithImageAsync(jsonImage.ToString(), jsonStomt.ToString())); }
/// <summary> /// Creates a new anonymous stomt on the specified target. /// </summary> /// <param name="positive">The stomt type. True for "I like" and false for "I wish".</param> /// <param name="target">The target to post the stomt to.</param> /// <param name="text">The stomt message.</param> public void CreateStomt(bool positive, string target, string text) { var json = new StringBuilder(); var writer = new LitJson.JsonWriter(json); writer.WriteObjectStart(); writer.WritePropertyName("anonym"); writer.Write(true); writer.WritePropertyName("positive"); writer.Write(positive); writer.WritePropertyName("target_id"); writer.Write(target); writer.WritePropertyName("text"); writer.Write(text); writer.WriteObjectEnd(); StartCoroutine(CreateStomtAsync(json.ToString())); }
public void InitiliazeConfig(string path) { var filePath = $"{path}\\PicPrompt.json"; if (!File.Exists(filePath)) { var writer = new LitJson.JsonWriter(); writer.WriteObjectStart(); writer.WritePropertyName("start-with-windows-enabled"); writer.Write(false); writer.WritePropertyName("allow-background-work"); writer.Write(true); writer.WriteObjectEnd(); File.WriteAllText(filePath, writer.ToString()); } Config.Load(filePath); }
private static void WriteValue(LitJson.JsonWriter jsonWriter, object val) { if (jsonWriter == null) { return; } if (val is int iVal) { jsonWriter.Write(iVal); } else if (val is long lVal) { jsonWriter.Write(lVal); } else if (val is ulong ulVal) { jsonWriter.Write(ulVal); } else if (val is double doVal) { jsonWriter.Write(doVal); } else if (val is decimal deVal) { jsonWriter.Write(deVal); } else if (val is bool bVal) { jsonWriter.Write(bVal); } else if (val is string sVal) { jsonWriter.Write(sVal); } }
public static void ToJson(ulong val, LitJson.JsonWriter writer) { writer.Write(val); }
public static void ToJson(double val, LitJson.JsonWriter writer) { writer.Write(val); }
public static void ToJson(decimal val, LitJson.JsonWriter writer) { writer.Write(val); }
static int _m_Write(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); LitJson.JsonWriter gen_to_be_invoked = (LitJson.JsonWriter)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 2 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2)) { bool _boolean = LuaAPI.lua_toboolean(L, 2); gen_to_be_invoked.Write(_boolean); return(0); } if (gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { double _number = LuaAPI.lua_tonumber(L, 2); gen_to_be_invoked.Write(_number); return(0); } if (gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { int _number = LuaAPI.xlua_tointeger(L, 2); gen_to_be_invoked.Write(_number); return(0); } if (gen_param_count == 2 && (LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) || LuaAPI.lua_isint64(L, 2))) { long _number = LuaAPI.lua_toint64(L, 2); gen_to_be_invoked.Write(_number); return(0); } if (gen_param_count == 2 && (LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) || LuaAPI.lua_isuint64(L, 2))) { ulong _number = LuaAPI.lua_touint64(L, 2); gen_to_be_invoked.Write(_number); return(0); } if (gen_param_count == 2 && (LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) || translator.IsDecimal(L, 2))) { decimal _number; translator.Get(L, 2, out _number); gen_to_be_invoked.Write(_number); return(0); } if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string _str = LuaAPI.lua_tostring(L, 2); gen_to_be_invoked.Write(_str); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to LitJson.JsonWriter.Write!")); }
public static void ExportSingle(float value, LitJson.JsonWriter writer) { writer.Write(value.ToString()); }
public static void ExportQuaternion(Quaternion value, LitJson.JsonWriter writer) { writer.Write(value.ToString()); }
public static void ExportVector4(Vector4 value, LitJson.JsonWriter writer) { writer.Write(value.ToString()); }