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 19:45Victor MerckléVictor MerckléScore: 3,154Success
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 19:513,13838,347,75919,962,0008,602,00092,725,248stderr
2Jul 7, 2026 19:513,15038,773,60920,010,0008,663,00092,778,496stderr
3Jul 7, 2026 19:513,15038,303,83520,046,0008,624,00092,782,592stderr
4Jul 7, 2026 19:513,15338,318,57920,029,0008,671,00092,778,496stderr
5Jul 7, 2026 19:513,15438,386,02220,023,0008,687,00092,741,632stderr
6Jul 7, 2026 19:513,16038,328,23720,005,0008,757,00092,762,112stderr
7Jul 7, 2026 19:513,17038,673,76520,099,0008,749,00092,758,016stderr
8Jul 7, 2026 19:513,17438,719,37920,130,0008,760,00092,704,768stderr
9Jul 7, 2026 19:513,19338,996,05820,066,0008,996,00092,667,904stderr