public SFJSONObject(String json) { JSONTokener readFrom = new JSONTokener(json); Object obj = readFrom.nextValue(); if (obj is SFJSONObject) { this.nameValuePairs = ((SFJSONObject)obj).nameValuePairs; } }
static JSONTokener GetRequest(string searchUrl) { //New Method var httpReq = (HttpWebRequest)WebRequest.Create(new Uri(searchUrl)); Stream objStream; objStream = httpReq.GetResponse().GetResponseStream(); JSONTokener j; var objReader = new StreamReader(objStream); var s1 = objReader.ReadToEnd(); j = new JSONTokener(s1); return(j); }
/// <summary> /// Returns a List of all pending scheduled notifications. /// </summary> /// <param name="context"></param> /// <returns></returns> public static List <Dictionary <string, string> > GetScheduledNotifications(Context context) { List <Dictionary <string, string> > result = new List <Dictionary <string, string> >(); var scheduledNotifications = context.GetSharedPreferences(CoreConstants.PreferenceName, FileCreationMode.Private).All; foreach (var statusBarNotification in scheduledNotifications) { JSONTokener tokener = new JSONTokener(statusBarNotification.Value.ToString()); var notification = new JSONObject(tokener); try { Dictionary <string, string> notificationMap = new Dictionary <string, string> { [NotificationConstants.Id] = notification.GetString(NotificationConstants.Id, null), [NotificationConstants.Title] = notification.GetString(NotificationConstants.Title, null), [NotificationConstants.Message] = notification.GetString(NotificationConstants.Message, null), [NotificationConstants.Ticker] = notification.GetString(NotificationConstants.Ticker, null), [NotificationConstants.Number] = notification.GetString(NotificationConstants.Number, null), [NotificationConstants.FireDate] = notification.GetString(NotificationConstants.FireDate, null), [NotificationConstants.ChannelId] = notification.GetString(NotificationConstants.ChannelId, null), [NotificationConstants.ChannelName] = notification.GetString(NotificationConstants.ChannelName, null), [NotificationConstants.Tag] = notification.GetString(NotificationConstants.Tag, null), [NotificationConstants.RepeatInterval] = notification.GetString(NotificationConstants.RepeatInterval, null), [NotificationConstants.SoundName] = notification.GetString(NotificationConstants.SoundName, null), }; result.Add(notificationMap); } catch (System.Exception e) { Log.Error($"{ MethodBase.GetCurrentMethod().Name}", e.ToString()); } } Log.Info(MethodBase.GetCurrentMethod().Name, result.ToString()); return(result); }
public static string Unescape(string escaped) { var tokenizer = new JSONTokener(escaped); return(tokenizer.NextValue().ToString()); }
public MainWindow() { InitializeComponent(); Regex p = new Regex("aa(bb)"); MatchCollection mc = p.Matches("hhaabbhh", 0); Console.WriteLine(mc.Count); Match m = p.Match("hhaabbhh"); if (m.Success) { Console.WriteLine(m.Groups[1].Value + " " + new Random().NextDouble()); } Dictionary <String, Object> dic = new Dictionary <String, Object>(); dic.Add("aa", "bb"); Dictionary <String, Object> .KeyCollection.Enumerator enu = dic.Keys.GetEnumerator(); //if (enu.MoveNext()) //{ // Console.WriteLine(enu.Current); //}; Console.WriteLine(enu.Current); String str = "{\"retcode\":10,\"result\":{\"gmasklist\":[{\"gid\":1000,\"mask\":0},{\"gid\":1638195794,\"mask\":0},{\"gid\":321105219,\"mask\":0}], \"gnamelist\":[{\"flag\":16777217,\"name\":\"iQQ\",\"gid\":1638195794,\"code\":2357062609},{\"flag\":1048577,\"name\":\"iQQ核心开发区\",\"gid\":321105219,\"code\":640215156}],\"gmarklist\":[]}}"; JSONTokener token = new JSONTokener(new StringReader(str)); JSONObject json = new JSONObject(token); Console.WriteLine(json.ToString()); //Console.WriteLine((Type.FONT==(Type)Enum.Parse(typeof(Type), "1", true))+""); //Console.WriteLine((Enum.Parse(typeof(Type), "text", true)) + ""); string jsStr = "( {'timeString':'Time is: ' + new Date(),'dateValue':new Date()} )"; FileInfo file = new FileInfo("C:\\Users\\leegean\\documents\\visual studio 2013\\Projects\\QQWpfApplication1\\WpfApplication1\\qq.js"); if (file.Exists) { StreamReader reader = file.OpenText(); jsStr = reader.ReadToEnd(); reader.Close(); } //Microsoft.JScript.JSObject obj = // (Microsoft.JScript.JSObject)JSEvaluator.EvalToObject(jsStr); // MessageBox.Show(obj["timeString"].ToString()); //MessageBox.Show(obj["dateValue"].ToString()); //Microsoft.JScript.DateObject tmpV = // (Microsoft.JScript.DateObject)obj["dateValue"]; //DateTime dt = // (DateTime)Microsoft.JScript.Convert.Coerce(tmpV, typeof(DateTime)); //MessageBox.Show(dt.ToString()); MSScriptControl.ScriptControlClass scc = new MSScriptControl.ScriptControlClass(); scc.Language = "javascript"; scc.Eval(jsStr); Console.WriteLine(scc.Eval("getPassword('lj19861001','1002053815','qwer');").ToString()); }