Checking JSON for correctness
PHP
Easy
json
Task «Checking JSON for correctness»
Write a program that reads a string containing JSON and checks whether it is valid JSON. If the string is valid JSON, output 'valid', otherwise output 'invalid'. The string may contain spaces and line breaks. It is guaranteed that the length of the string does not exceed 1000 characters.
Input Format
One line containing JSON.
Output Format
One line: 'valid' or 'invalid'.
Examples
Example 1
INPUT
2
A B 500 1
C D 500 2
OUTPUT
invalid
Example 2
INPUT
{"key": "value"}
OUTPUT
valid
Example 3
INPUT
0
OUTPUT
valid
main.php