#C13196. JSON Object Serialization and Deserialization
JSON Object Serialization and Deserialization
JSON Object Serialization and Deserialization
You are given a JSON representation of a custom object which has two attributes: attribute1
and attribute2
. Your task is to simulate the process of serialization and deserialization. In other words, you need to read the two attributes from standard input, construct the corresponding object, simulate converting it into a JSON string and then parsing this JSON string back into an object, and finally output the two attributes in order.
Note: Both input lines are valid JSON. For example, a string will be provided with quotes. Your solution should remove the quotes when printing string values. For non-string types (like numbers, arrays, or objects), output them in canonical JSON format. In particular, for arrays or objects, ensure that commas and colons are followed by a space (if not already present) as in the standard JSON formatting.
Example: if the input is
"hello" [1,2,3]then the output should be
hello [1, 2, 3]
inputFormat
The input consists of two lines:
- The first line is a JSON representation of
attribute1
(a string). - The second line is a JSON representation of
attribute2
, which may be a number, an array, an object, or a string.
You must read these two lines from standard input.
outputFormat
Output two lines to standard output:
- The first line is the value of
attribute1
. If it is a string, print it without the surrounding quotes. - The second line is the value of
attribute2
in canonical JSON format. For non-string types, use standard JSON formatting with a space after commas and colons.
"value1"
2
value1
2
</p>