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 04:53Andrew EpsteinAndrew EpsteinScore: 2,438Success
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 05:242,41130,964,15313,479,0008,465,00092,786,688
2Nov 5, 2026 05:242,42130,953,23213,587,0008,446,00092,729,344
3Nov 5, 2026 05:242,43031,593,54513,680,0008,439,00092,745,728
4Nov 5, 2026 05:242,43331,188,05313,588,0008,560,00092,745,728
5Nov 5, 2026 05:242,43832,785,44813,732,0008,459,00092,778,496
6Nov 5, 2026 05:242,44131,232,34113,677,0008,538,00092,729,344
7Nov 5, 2026 05:242,44631,293,13713,810,0008,456,00092,741,632
8Nov 5, 2026 05:242,44831,300,91713,787,0008,493,00092,753,920
9Nov 5, 2026 05:242,46031,459,75213,816,0008,578,00092,745,728