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 listMar 13, 2026 12:33Dominique GarmierDominique GarmierScore: 14,973Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 13, 2026 12:3314,931154,386,098120,889,00014,986,00094,539,776
2Mar 13, 2026 12:3314,937160,171,344119,935,00015,991,00094,543,872
3Mar 13, 2026 12:3314,948157,228,484116,026,00020,004,00094,543,872
4Mar 13, 2026 12:3314,949165,528,026122,029,00014,003,00094,556,160
5Mar 13, 2026 12:3314,973165,472,225117,215,00019,035,00094,797,824
6Mar 13, 2026 12:3314,992163,529,433113,521,00022,903,00094,564,352
7Mar 13, 2026 12:3314,993162,339,342113,533,00022,905,00094,539,776
8Mar 13, 2026 12:3314,998163,922,828114,567,00021,917,00094,564,352
9Mar 13, 2026 12:3315,009163,915,518122,625,00013,957,00094,642,176