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 16, 2026 10:55Dominique GarmierDominique GarmierScore: 12,418Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 16, 2026 10:5512,308134,495,71393,003,00019,000,00094,564,352
2Mar 16, 2026 10:5512,335140,042,56495,212,00017,038,00094,564,352
3Mar 16, 2026 10:5512,365139,931,79694,598,00017,923,00094,556,160
4Mar 16, 2026 10:5512,369140,665,94592,634,00019,921,00094,556,160
5Mar 16, 2026 10:5512,418138,046,17295,003,00018,000,00094,691,328
6Mar 16, 2026 10:5512,483139,804,13097,653,00015,943,00094,564,352
7Mar 16, 2026 10:5512,524141,429,19994,975,00018,995,00094,564,352
8Mar 16, 2026 10:5512,636137,323,58695,987,00018,997,00094,564,352
9Mar 16, 2026 10:5512,657139,208,02597,149,00018,027,00094,539,776