79562846

Date: 2025-04-08 18:56:07
Score: 1
Natty:
Report link

Using JToken from Newtonsoft.Json library, you can do the following to minify a JSON string:

var jsonString = "{\n  \"something\": \"test\",\n  \"somethingElse\": 2\n}";
var minifiedJson = JToken.Parse(jsonString).ToString(Formatting.None);

No need to serialize and then de-serialize.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Polaris