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 8, 2026 03:42Victor MerckléVictor MerckléScore: 3,701Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 8, 2026 03:473,67042,411,08116,708,00016,691,00094,392,320
2Jun 8, 2026 03:473,68042,555,25416,720,00016,769,00094,392,320
3Jun 8, 2026 03:473,69342,716,06416,720,00016,895,00094,392,320
4Jun 8, 2026 03:473,69742,772,73716,680,00016,968,00094,392,320
5Jun 8, 2026 03:473,70142,735,31516,278,00017,403,00094,392,320
6Jun 8, 2026 03:473,70242,794,90716,291,00017,400,00094,392,320
7Jun 8, 2026 03:473,71542,898,79516,792,00017,017,00094,392,320
8Jun 8, 2026 03:473,72343,000,84817,094,00016,786,00094,392,320
9Jun 8, 2026 03:473,72543,000,36716,423,00017,476,00094,392,320