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 listAug 19, 2026 06:15Victor MerckléVictor MerckléScore: 2,801Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 06:212,78333,739,27716,773,0008,561,00092,753,920stderr
2Aug 19, 2026 06:212,79133,741,86716,818,0008,585,00092,725,248stderr
3Aug 19, 2026 06:212,79333,817,87416,818,0008,605,00092,803,072stderr
4Aug 19, 2026 06:212,79733,750,50316,827,0008,626,00092,733,440stderr
5Aug 19, 2026 06:212,80133,790,70016,864,0008,629,00092,745,728stderr
6Aug 19, 2026 06:212,80233,772,04516,879,0008,628,00092,700,672stderr
7Aug 19, 2026 06:212,81334,077,47916,898,0008,702,00092,712,960stderr
8Aug 19, 2026 06:212,81835,209,86016,947,0008,704,00092,803,072stderr
9Aug 19, 2026 06:212,82134,113,94116,990,0008,683,00092,807,168stderr