← 返回 snowflake 的题目列表Implement a JSON Parser
类型:online_judge
Problem
Implement a simplified JSON parser.
Given a string representing a JSON value, parse it and print an equivalent compact JSON string with unnecessary whitespace removed. If the input is invalid JSON, print INVALID.
Supported JSON Types
object
array
string
number
boolean
null
String Requirements
Support common escapes:
quote
backslash
slash
b, f, n, r, t
unicode escape
Number Requirements
Support:
integer
negative number
decimal number
exponent notation
Input
stdin contains one JSON value, possibly with spaces and newlines.
Output
If the input is valid, print compact JSON.
If the input is invalid, print INVALID.
Constraints
Input length is at most 200000.
Nesting depth is at most 1000.
Example
Input
{"a":1,"b":[true,null,"x"]}
Output
{"a":1,"b":[true,null,"x"]}