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 listJul 7, 2026 04:14Victor MerckléVictor MerckléScore: 2,680Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 7, 2026 04:212,65932,720,97215,455,0008,745,00092,737,536stderr
2Jul 7, 2026 04:212,67532,402,62115,545,0008,803,00092,753,920stderr
3Jul 7, 2026 04:212,67732,432,12015,536,0008,832,00092,721,152stderr
4Jul 7, 2026 04:212,67832,319,21315,565,0008,813,00092,770,304stderr
5Jul 7, 2026 04:212,68032,278,73715,537,0008,856,00092,700,672stderr
6Jul 7, 2026 04:212,68232,286,20215,530,0008,881,00092,717,056stderr
7Jul 7, 2026 04:212,68732,676,54915,631,0008,828,00092,721,152stderr
8Jul 7, 2026 04:212,69532,531,68215,607,0008,921,00092,729,344stderr
9Jul 7, 2026 04:212,70833,086,08115,637,0009,011,00092,733,440stderr