XML to JSON Sergey Svistunov

Convert 1,000,000 person records from XML to JSON as fast as possible.

Input

XML document on STDIN:

<?xml version="1.0" encoding="UTF-8"?>
<persons>
    <person id="1512376">
        <age>30</age>
        <height>169.1</height>
        <married>true</married>
        <phone code="+6"><number>1283603279</number></phone>
        <phone code="+6"><number>1659964668</number></phone>
    </person>
    ...
</persons>

Output

One JSON object per person to STDOUT, preserving order:

{
    "id": 1512376,
    "age": 30,
    "height": 169.1,
    "married": true,
    "phones": [
        {
            "code": "+6",
            "number": 1283603279
        },
        {
            "code": "+6",
            "number": 1659964668
        }
    ]
}

Constraints

  • Preserve the order of persons
  • Omit the phones field if the phone array is empty
  • Maximum number of phones per person is 3
Back to listMay 3, 2026 17:45TudyMTudyMScore: 8,557Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 17:518,52795,749,02360,208,00017,389,00094,629,888
2May 3, 2026 17:518,53293,264,60161,104,00016,541,00094,642,176
3May 3, 2026 17:518,54194,756,97160,988,00016,739,00094,629,888
4May 3, 2026 17:518,54793,806,03061,250,00016,532,00094,633,984
5May 3, 2026 17:518,55795,838,95260,490,00017,383,00094,633,984
6May 3, 2026 17:518,56293,686,60960,536,00017,379,00094,621,696
7May 3, 2026 17:518,56496,025,52760,476,00017,458,00094,638,080
8May 3, 2026 17:518,56591,901,90060,433,00017,517,00094,642,176
9May 3, 2026 17:518,56691,629,05060,634,00017,324,00094,638,080