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,249Success
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:353,23440,259,57021,013,0008,424,00092,729,344
2Nov 3, 2026 02:353,23640,278,44421,001,0008,452,00092,733,440
3Nov 3, 2026 02:353,23940,313,72121,016,0008,465,00092,778,496
4Nov 3, 2026 02:353,24840,363,75821,006,0008,554,00092,766,208
5Nov 3, 2026 02:353,24940,361,27621,036,0008,530,00092,704,768
6Nov 3, 2026 02:353,25341,032,46521,106,0008,501,00092,733,440
7Nov 3, 2026 02:353,25841,047,94320,950,0008,698,00092,762,112
8Nov 3, 2026 02:353,26041,400,50121,146,0008,527,00092,782,592
9Nov 3, 2026 02:353,28142,163,16621,055,0008,805,00092,786,688