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 16, 2026 07:20marko1597marko1597Score: 3,934Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 07:353,91444,029,38727,360,0008,266,00092,712,960stderr
2Aug 16, 2026 07:353,91944,077,36327,361,0008,310,00092,680,192stderr
3Aug 16, 2026 07:353,92244,069,45027,348,0008,351,00092,782,592stderr
4Aug 16, 2026 07:353,92744,830,54927,381,0008,361,00092,758,016stderr
5Aug 16, 2026 07:353,93444,047,17927,394,0008,412,00092,741,632stderr
6Aug 16, 2026 07:353,93644,222,53427,377,0008,441,00092,737,536stderr
7Aug 16, 2026 07:353,93945,021,58327,427,0008,422,00092,725,248stderr
8Aug 16, 2026 07:353,94143,997,20827,390,0008,480,00092,745,728stderr
9Aug 16, 2026 07:353,94745,040,79227,413,0008,505,00092,688,384stderr