#C13488. Normalize User Data
Normalize User Data
Normalize User Data
You are given a JSON array of user objects. Each object might contain the fields "name", "age", and "email". Your task is to normalize the input data as follows:
- Every user object must have the keys
name
,age
, andemail
. If a key is missing, its value should be set to null (i.e. \(\texttt{null}\)). - If the
email
exists, convert all its characters to lowercase.
The normalized output should be a JSON array of user objects with these changes applied.
Input/Output: The program will read input from standard input (stdin) and must write the final normalized JSON array to standard output (stdout).
Note: The input is guaranteed to be a single valid JSON array.
inputFormat
The input consists of a single JSON array provided through stdin. Each element in the array is a JSON object that may contain the keys name
, age
, and email
.
outputFormat
Output a normalized JSON array to stdout. Each object in the output array must include the keys name
, age
, and email
(in that order). Missing keys should have a null
value, and any present email
value must be converted to lowercase.
[{"name": "Alice", "age": 30, "email": "ALICE@EXAMPLE.COM"}, {"name": "Bob", "age": 25, "email": "bob@example.com"}]
[{"name":"Alice","age":30,"email":"alice@example.com"},{"name":"Bob","age":25,"email":"bob@example.com"}]