예제 #1
0
        public void Test_GetJson()
        {
            string jsonp  = @"jsonp({""a"":""1234"",""b"":9999})";
            var    json   = "{\"a\":\"1234\",\"b\":9999}";
            var    result = Regexs.GetValue(jsonp, @"^\w+\((\{[^()]+\})\)$", "$1");

            Output.WriteLine(result);
            Assert.Equal(json, result);
        }
예제 #2
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="data">数据</param>
        public override void LoadData(string data)
        {
            if (data.IsEmpty())
            {
                return;
            }
            data = data.Trim().TrimEnd(';');
            var json = Regexs.GetValue(data, @"^\w+\((\s+\{[^()]+\}\s+)\)$", "$1");

            if (json.IsEmpty())
            {
                return;
            }
            var jObject = JObject.Parse(json);

            foreach (var token in jObject.Children())
            {
                AddNodes(token);
            }
        }