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 03:23Andrew EpsteinAndrew EpsteinScore: 2,957Success
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 03:292,93737,535,07918,251,0008,477,00092,745,728
2Nov 3, 2026 03:292,94737,652,76318,324,0008,494,00092,741,632
3Nov 3, 2026 03:292,95138,289,42018,370,0008,488,00092,774,400
4Nov 3, 2026 03:292,95237,760,23918,365,0008,503,00092,737,536
5Nov 3, 2026 03:292,95737,760,06618,402,0008,511,00092,762,112
6Nov 3, 2026 03:292,96438,087,63918,449,0008,524,00092,745,728
7Nov 3, 2026 03:292,96737,916,03318,432,0008,570,00092,786,688
8Nov 3, 2026 03:292,98638,118,68818,491,0008,684,00092,819,456
9Nov 3, 2026 03:292,98838,559,00118,531,0008,666,00092,688,384