public static Task <JSONDataMap> GetValueMapAsync(Uri uri, RequestParams request) { return(GetStringAsync(uri, request) .ContinueWith((antecedent) => { var response = antecedent.Result; return response.IsNotNullOrWhiteSpace() ? JSONDataMap.FromURLEncodedString(response) : null; })); }
public void JSONDataMapFromURLEncoded_KeyEmptyEqNormal() { var dict = JSONDataMap.FromURLEncodedString("a=&b&&=&=14&c=3459"); Assert.AreEqual(3, dict.Count); Assert.AreEqual(string.Empty, dict["a"]); Assert.AreEqual(null, dict["b"]); Assert.AreEqual("3459", dict["c"]); }
public static JSONDataMap GetValueMap(Uri uri, IWebClientCaller caller, HTTPRequestMethod method = HTTPRequestMethod.GET, IDictionary <string, string> queryParameters = null, IDictionary <string, string> bodyParameters = null, IDictionary <string, string> headers = null) { string responseStr = GetString(uri, caller, method, queryParameters: queryParameters, bodyParameters: bodyParameters, headers: headers); var dict = JSONDataMap.FromURLEncodedString(responseStr); return(dict); }
public void JSONDataMapFromURLEncoded_Esc() { string[] strs = { " ", "!", "=", "&", "\"zele/m\\h()an\"" }; foreach (var str in strs) { var query = "a=" + Uri.EscapeDataString(str); var dict = JSONDataMap.FromURLEncodedString(query); Aver.AreEqual(1, dict.Count); Aver.AreObjectsEqual(str, dict["a"]); } }
public static JSONDataMap DecodeState(string state) { try { var str = state.Replace('_', '/').Replace('-', '+'); switch (state.Length % 4) { case 2: str += "=="; break; case 3: str += "="; break; } var url = Encoding.UTF8.GetString(Convert.FromBase64String(str)); return(JSONDataMap.FromURLEncodedString(url)); } catch (Exception) { return(new JSONDataMap()); } }
public void JSONDataMapFromURLEncoded_WOAmpVal() { var dict = JSONDataMap.FromURLEncodedString("=1"); Aver.AreEqual(0, dict.Count); }
public static JSONDataMap GetValueMap(Uri uri, RequestParams request) { string response = GetString(uri, request); return(response.IsNotNullOrWhiteSpace() ? JSONDataMap.FromURLEncodedString(response) : null); }