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:49Andrew EpsteinAndrew EpsteinScore: 3,204Success
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:063,18739,814,68520,575,0008,430,00092,733,440
2Nov 3, 2026 03:063,18940,900,60020,602,0008,419,00092,725,248
3Nov 3, 2026 03:063,19439,868,14320,600,0008,469,00092,708,864
4Nov 3, 2026 03:063,19939,928,99020,637,0008,481,00092,811,264
5Nov 3, 2026 03:063,20439,991,92720,484,0008,679,00092,782,592
6Nov 3, 2026 03:063,21140,543,24120,719,0008,504,00092,692,480
7Nov 3, 2026 03:063,21540,095,13820,691,0008,566,00092,741,632
8Nov 3, 2026 03:063,21740,173,75920,568,0008,707,00092,807,168
9Nov 3, 2026 03:063,21940,057,81420,737,0008,563,00092,741,632