#C14824. Prettify JSON String
Prettify JSON String
Prettify JSON String
You are given a single string representing JSON data from standard input (STDIN). Your task is to parse this JSON string and output a prettified version of the JSON with an indentation of 2 spaces. If the provided string is not a valid JSON, output Invalid JSON string
.
The prettified JSON should follow the standard JSON format with proper newlines and indentation as illustrated in the examples.
Note: All input is provided via STDIN and your output should be sent to STDOUT.
inputFormat
The input consists of a single JSON string. This string may represent a JSON object or a JSON array. The entire JSON string is provided via standard input.
outputFormat
If the provided input is a valid JSON string, output its prettified version with an indentation of 2 spaces. If the input is not valid, output exactly: Invalid JSON string## sample
{"name":"John","age":30}
{
"name": "John",
"age": 30
}
</p>