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:26Andrew EpsteinAndrew EpsteinScore: 3,160Success
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 04:533,14139,469,58320,153,0008,439,00092,758,016
2Nov 3, 2026 04:533,14239,458,54420,124,0008,475,00092,782,592
3Nov 3, 2026 04:533,15039,550,93420,200,0008,473,00092,774,400
4Nov 3, 2026 04:533,15139,544,21820,196,0008,484,00092,774,400
5Nov 3, 2026 04:533,16040,156,53920,260,0008,499,00092,753,920
6Nov 3, 2026 04:533,16739,676,26220,122,0008,701,00092,798,976
7Nov 3, 2026 04:533,16840,148,70620,291,0008,543,00092,762,112
8Nov 3, 2026 04:533,17839,821,30920,301,0008,620,00092,729,344
9Nov 3, 2026 04:533,19641,960,25720,322,0008,764,00092,762,112