コード例 #1
0
        public ActionResult Eval(string expression)
        {
            try
            {
                var result = _webShell.Eval(expression);

                //if (result == null)
                //    return Json(new { success = true, result = "<null>" });

                var prettifyOutput = JsonConvert.SerializeObject(result, Formatting.Indented);

                return(Json(new { success = true, result = prettifyOutput }));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, result = ex.Message }));
            }
        }
コード例 #2
0
        public ActionResult Eval(string expression)
        {
            try
            {
                var result = _webShell.Eval(expression);

                //if (result == null)
                //    return Json(new { success = true, result = "<null>" });

                var options = new JsonSerializerOptions {
                    WriteIndented = true
                };
                var prettifyOutput = JsonSerializer.Serialize(result, options);

                return(Json(new { success = true, result = prettifyOutput }));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, result = ex.Message }));
            }
        }