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 listNov 3, 2026 04:28Andrew EpsteinAndrew EpsteinScore: 2,934Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 05:042,91737,405,49018,085,0008,468,00092,741,632
2Nov 3, 2026 05:042,91937,484,08518,080,0008,487,00092,745,728
3Nov 3, 2026 05:042,92537,359,59718,111,0008,512,00092,704,768
4Nov 3, 2026 05:042,93137,628,54418,075,0008,606,00092,667,904
5Nov 3, 2026 05:042,93438,099,79318,129,0008,576,00092,745,728
6Nov 3, 2026 05:042,93538,118,77818,172,0008,543,00092,758,016
7Nov 3, 2026 05:042,95838,274,35418,249,0008,672,00092,798,976
8Nov 3, 2026 05:042,96038,293,55018,262,0008,676,00092,794,880
9Nov 3, 2026 05:042,96338,313,75518,326,0008,645,00092,733,440