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 5, 2026 06:33Andrew EpsteinAndrew EpsteinScore: 2,388Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 5, 2026 07:032,37730,901,04112,969,0008,663,00092,741,632
2Nov 5, 2026 07:032,38231,025,83213,131,0008,546,00092,823,552
3Nov 5, 2026 07:032,38630,864,50213,097,0008,620,00092,729,344
4Nov 5, 2026 07:032,38732,891,29213,159,0008,563,00092,745,728
5Nov 5, 2026 07:032,38830,903,70813,166,0008,565,00092,659,712
6Nov 5, 2026 07:032,38830,844,67713,149,0008,585,00092,721,152
7Nov 5, 2026 07:032,39030,892,44413,145,0008,608,00092,762,112
8Nov 5, 2026 07:032,39831,205,03613,149,0008,681,00092,758,016
9Nov 5, 2026 07:032,41031,185,17113,241,0008,692,00092,729,344