Parse() public method

public Parse ( ) : UnityEditorInternal.JSONValue
return UnityEditorInternal.JSONValue
Ejemplo n.º 1
0
 public static JSONValue SimpleParse(string jsondata)
 {
   JSONParser jsonParser = new JSONParser(jsondata);
   try
   {
     return jsonParser.Parse();
   }
   catch (JSONParseException ex)
   {
     Debug.LogError((object) ex.Message);
   }
   return new JSONValue((object) null);
 }
Ejemplo n.º 2
0
 public static JSONValue SimpleParse(string jsondata)
 {
     JSONParser parser = new JSONParser(jsondata);
     try
     {
         return parser.Parse();
     }
     catch (JSONParseException exception)
     {
         Debug.LogError(exception.Message);
     }
     return new JSONValue(null);
 }
Ejemplo n.º 3
0
		private static Dictionary<string, JSONValue> ParseJSON(string content, out string status, out string message)
		{
			message = null;
			status = null;
			JSONValue jSONValue;
			try
			{
				JSONParser jSONParser = new JSONParser(content);
				jSONValue = jSONParser.Parse();
			}
			catch (JSONParseException ex)
			{
				Debug.Log("Error parsing server reply: " + content);
				Debug.Log(ex.Message);
				Dictionary<string, JSONValue> result = null;
				return result;
			}
			Dictionary<string, JSONValue> dictionary;
			try
			{
				dictionary = jSONValue.AsDict(true);
				if (dictionary == null)
				{
					Debug.Log("Error parsing server message: " + content);
					Dictionary<string, JSONValue> result = null;
					return result;
				}
				if (dictionary.ContainsKey("result") && dictionary["result"].IsDict())
				{
					dictionary = dictionary["result"].AsDict(true);
				}
				if (dictionary.ContainsKey("message"))
				{
					message = dictionary["message"].AsString(true);
				}
				if (dictionary.ContainsKey("status"))
				{
					status = dictionary["status"].AsString(true);
				}
				else
				{
					if (dictionary.ContainsKey("error"))
					{
						status = dictionary["error"].AsString(true);
						if (status == string.Empty)
						{
							status = "ok";
						}
					}
					else
					{
						status = "ok";
					}
				}
			}
			catch (JSONTypeException ex2)
			{
				Debug.Log("Error parsing server reply. " + content);
				Debug.Log(ex2.Message);
				Dictionary<string, JSONValue> result = null;
				return result;
			}
			return dictionary;
		}