// Parsing JSON string string jsonString = "{\"name\":\"John\", \"age\":30}"; JSONNode jsonNode = JSON.Parse(jsonString); // Get string representation of JSONNode object string jsonString2 = jsonNode.ToString();
// Creating a JSON object JSONNode jsonObject = new JSONObject(); jsonObject.Add("name", "John"); jsonObject.Add("age", 30); // Get string representation of the JSON object string jsonString = jsonObject.ToString();In this example, we create a JSON object using the SimpleJSON library and add some key-value pairs to it. We then convert the JSON object to its string representation using the ToString method. Package library: SimpleJSON library.