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 listOct 17, 2026 08:05janwwwjanwwwScore: 3,568Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 17, 2026 08:103,55843,251,26523,872,0008,514,00092,721,152
2Oct 17, 2026 08:103,56245,074,98923,786,0008,630,00092,725,248
3Oct 17, 2026 08:103,56343,297,83523,756,0008,676,00092,659,712
4Oct 17, 2026 08:103,56343,186,25323,905,0008,525,00092,835,840
5Oct 17, 2026 08:103,56843,324,55223,897,0008,576,00092,778,496
6Oct 17, 2026 08:103,56943,240,65923,796,0008,687,00092,786,688
7Oct 17, 2026 08:103,58143,432,19723,944,0008,648,00092,712,960
8Oct 17, 2026 08:103,58243,399,37423,926,0008,672,00092,770,304
9Oct 17, 2026 08:103,58543,526,90523,951,0008,680,00092,745,728