← 返回 microsoft 的题目列表Validate JSON String
类型:online_judge
Write a function to validate if a given string is a valid JSON format. The string may contain arbitrary whitespace and JSON-supported structures like objects, arrays, strings, numbers, booleans, and null. The function should return a boolean indicating if the string is valid JSON. Handle various nested structures and illegal characters appropriately.
Input:
A string s representing the JSON string to validate.
Output:
A boolean indicating whether the string is a valid JSON.
Example:
Input: ' { "name": "John", "age": 30, "car": null } '
Output: True
Input: ' { name: "John" } '
Output: False
Constraints:
The string length is between 1 and 10^6.
Example
Input
' { "name": "John", "age": 30, "car": null } '