Example #1
0
 public IActionResult JsonFormat(JsonFormatViewModel model)
 {
     try
     {
         if (model.Format)
         {
             var dybject = JsonConvert.DeserializeObject(model.SourceString);
             model.ResultString = JsonConvert.SerializeObject(dybject, Formatting.Indented);
         }
         else
         {
             var dybject = JsonConvert.DeserializeObject(model.SourceString);
             model.ResultString = JsonConvert.SerializeObject(dybject, Formatting.None);
         }
     }
     catch (Exception e)
     {
         model.ResultString = $"Invalid input! Error message: \r\n{e.Message} \r\n {e.StackTrace}";
     }
     return(View(model));
 }
Example #2
0
        public IActionResult JsonFormat()
        {
            var model = new JsonFormatViewModel();

            return(View(model));
        }