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 02:19Andrew EpsteinAndrew EpsteinScore: 3,216Success
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 02:293,18839,916,62620,593,0008,425,00092,774,400
2Nov 3, 2026 02:293,19539,887,51220,651,0008,424,00092,803,072
3Nov 3, 2026 02:293,20640,666,37220,673,0008,506,00092,753,920
4Nov 3, 2026 02:293,21540,212,51820,718,0008,540,00092,663,808
5Nov 3, 2026 02:293,21640,619,83520,744,0008,527,00092,758,016
6Nov 3, 2026 02:293,21840,342,03620,637,0008,650,00092,762,112
7Nov 3, 2026 02:293,22040,213,55920,792,0008,513,00092,745,728
8Nov 3, 2026 02:293,22741,687,68520,665,0008,705,00092,729,344
9Nov 3, 2026 02:293,22840,236,73220,776,0008,603,00092,815,360