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)); }
public IActionResult JsonFormat() { var model = new JsonFormatViewModel(); return(View(model)); }