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 listJun 5, 2026 16:05Victor MerckléVictor MerckléScore: 3,027Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 5, 2026 16:103,01336,493,86118,752,0008,675,00092,778,496
2Jun 5, 2026 16:103,01736,504,53918,948,0008,508,00092,741,632
3Jun 5, 2026 16:103,01936,570,30418,853,0008,624,00092,786,688
4Jun 5, 2026 16:103,02636,567,07018,915,0008,628,00092,749,824
5Jun 5, 2026 16:103,02736,694,06518,863,0008,691,00092,725,248
6Jun 5, 2026 16:103,02936,718,84918,902,0008,664,00092,737,536
7Jun 5, 2026 16:103,02936,575,17218,782,0008,787,00092,786,688
8Jun 5, 2026 16:103,02936,573,61318,880,0008,689,00092,737,536
9Jun 5, 2026 16:103,04436,787,11918,928,0008,781,00092,778,496