Example #1
0
        public static void CustomSerialization(Dictionary <string, object> dict, LitJson.JsonWriter jsonWriter)
        {
            jsonWriter.WriteObjectStart();
            foreach (var dictKey in dict.Keys)
            {
                var val = dict[dictKey];

                if (_customTypes.Contains(val.GetType()))
                {
                    // 可以写入的类型
                    jsonWriter.WritePropertyName(dictKey);
                    WriteValue(jsonWriter, val);
                }
                else if (val is Dictionary <string, object> subDic)
                {
                    jsonWriter.WritePropertyName(dictKey);
                    CustomSerialization(subDic, jsonWriter);
                }
            }
            jsonWriter.WriteObjectEnd();
        }
Example #2
0
        static int _m_WritePropertyName(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                LitJson.JsonWriter gen_to_be_invoked = (LitJson.JsonWriter)translator.FastGetCSObj(L, 1);



                {
                    string _property_name = LuaAPI.lua_tostring(L, 2);

                    gen_to_be_invoked.WritePropertyName(_property_name);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Example #3
0
 public void Write(string name, decimal value)
 {
     _writer.WritePropertyName(name);
     JsonMapper.ToJson(value, _writer);
 }