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 listSep 14, 2026 22:12Andrew EpsteinAndrew EpsteinScore: 3,491Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 22:343,48141,933,03823,099,0008,586,00092,712,960
2Sep 14, 2026 22:343,48542,738,13323,302,0008,413,00092,729,344
3Sep 14, 2026 22:343,48542,018,06723,031,0008,688,00092,770,304
4Sep 14, 2026 22:343,49042,058,05123,298,0008,462,00092,717,056
5Sep 14, 2026 22:343,49142,813,57223,320,0008,454,00092,758,016
6Sep 14, 2026 22:343,49242,769,64123,323,0008,461,00092,725,248
7Sep 14, 2026 22:343,49542,820,76223,198,0008,613,00092,704,768
8Sep 14, 2026 22:343,50542,461,96823,246,0008,652,00092,704,768
9Sep 14, 2026 22:343,50842,972,62923,269,0008,660,00092,721,152