예제 #1
0
    private CSJSONObject parseArray()
    {
        CSJSONObject a = new CSJSONObject();

        a.f_eObjType = EJSONObjectType.eJOT_Array;
        NextToken();
        if (token.type == CSJSONTokenType.RIGHT_BRACKET)
        {
            return(a);
        }
        while (true)
        {
            a.push(ParseValue());
            NextToken();
            if (token.type == CSJSONTokenType.RIGHT_BRACKET)
            {
                return(a);
            }
            else if (token.type == CSJSONTokenType.COMMA)
            {
                NextToken();
            }
            else
            {
                Debug.LogError("Expecting ] or , but found " + token.value);
                return(null);
            }
        }
    }
예제 #2
0
    private string ConvertToString(CSJSONObject value)
    {
        if (value == null)
        {
            return("null");
        }
        switch (value.f_eObjType)
        {
        case EJSONObjectType.eJOT_String:
            return(EscapeString(value.GetString()));

        case EJSONObjectType.eJOT_Int:
            return(value.GetInt().ToString());

        case EJSONObjectType.eJOT_Float:
            return(value.GetFloat().ToString());

        case EJSONObjectType.eJOT_Bool:
            return(value.GetBool() ? "true" : "false");

        case EJSONObjectType.eJOT_Array:
            return(ArrayToString(value.GetArray()));

        case EJSONObjectType.eJOT_Object:
            return(ObjectToString(value.GetObject()));
        }
        return("null");
    }
예제 #3
0
파일: CSConnect.cs 프로젝트: Joky8926/EF
    public static void SendMsg(string mod, string d, MsgCallbackDelegate func, CSJSONObject obj = null)
    {
//		string sUrl = CSUrlConst.API;
//		string sHashKey = CSGameMain.f_Common.f_sHashKey;
//		if (sHashKey == null || sHashKey == "") {
//			return;
//		}
//		sUrl += "?m=" + mod + "&d=" + d + "&r=" + CSJSON.Encode(obj) + "&hashKey=" + sHashKey + "&t=" + Random.value;
//		CallbackDelegate callback = (string sData) => {
//			func(CSJSON.Decode(sData));
//		};
//		SCRMain.Coroutine(HttpRequest(sUrl, callback));
    }
예제 #4
0
    private CSJSONObject parseObject()
    {
        CSJSONObject o = new CSJSONObject();

        o.f_eObjType = EJSONObjectType.eJOT_Object;
        string key;

        NextToken();
        if (token.type == CSJSONTokenType.RIGHT_BRACE)
        {
            return(o);
        }
        while (true)
        {
            if (token.type == CSJSONTokenType.STRING)
            {
                key = token.stringValue;
                NextToken();
                if (token.type == CSJSONTokenType.COLON)
                {
                    NextToken();
                    o[key] = ParseValue();
                    NextToken();
                    if (token.type == CSJSONTokenType.RIGHT_BRACE)
                    {
                        return(o);
                    }
                    else if (token.type == CSJSONTokenType.COMMA)
                    {
                        NextToken();
                    }
                    else
                    {
                        Debug.LogError("Expecting } or , but found " + token.value);
                        return(null);
                    }
                }
                else
                {
                    Debug.LogError("Expecting : but found " + token.value);
                    return(null);
                }
            }
            else
            {
                Debug.LogError("Expecting string but found " + token.value);
                return(null);
            }
        }
    }
예제 #5
0
 public void push(CSJSONObject obj)
 {
     m_lstObject.Add(obj);
 }
예제 #6
0
 public CSJSONDecoder(string s)
 {
     tokenizer = new CSJSONTokenizer(s);
     NextToken();
     value = ParseValue();
 }
예제 #7
0
파일: CSJSON.cs 프로젝트: Joky8926/EF
    public static string Encode(CSJSONObject o)
    {
        CSJSONEncoder encoder = new CSJSONEncoder(o);

        return(encoder.GetString());
    }
예제 #8
0
 public CSJSONEncoder(CSJSONObject value)
 {
     jsonString = ConvertToString(value);
 }