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 listApr 22, 2026 14:26Dominique GarmierDominique GarmierScore: 6,542Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 14:286,53078,580,44140,287,00019,136,00094,605,312
2Apr 22, 2026 14:286,53675,632,20637,304,00022,180,00094,617,600
3Apr 22, 2026 14:286,54075,403,49040,353,00019,167,00094,613,504
4Apr 22, 2026 14:286,54181,135,05240,357,00019,169,00094,617,600
5Apr 22, 2026 14:286,54278,931,70040,365,00019,173,00094,617,600
6Apr 22, 2026 14:286,54577,492,34631,766,00027,796,00094,597,120
7Apr 22, 2026 14:286,55577,132,40233,803,00025,849,00094,781,440
8Apr 22, 2026 14:286,55973,420,45033,824,00025,865,00094,605,312
9Apr 22, 2026 14:286,59077,705,90433,983,00025,987,00094,597,120