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 19, 2026 00:04Dominique GarmierDominique GarmierScore: 7,148Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 19, 2026 00:047,12289,402,38246,860,00017,946,00094,539,776
2Mar 19, 2026 00:047,12292,543,65949,854,00014,956,00094,564,352
3Mar 19, 2026 00:047,12392,937,53349,860,00014,958,00094,564,352
4Mar 19, 2026 00:047,14591,104,56246,011,00019,004,00094,564,352
5Mar 19, 2026 00:047,14889,893,95447,036,00018,014,00094,797,824
6Mar 19, 2026 00:047,16189,081,00045,112,00020,050,00094,539,776
7Mar 19, 2026 00:047,17297,213,63247,189,00018,072,00094,564,352
8Mar 19, 2026 00:047,17492,799,23448,467,00016,815,00094,793,728
9Mar 19, 2026 00:047,18087,756,52048,248,00017,087,00094,564,352