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 24, 2026 22:29olliecrowolliecrowScore: 5,309Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 24, 2026 22:315,27967,708,88928,023,00020,016,00094,806,016
2Apr 24, 2026 22:315,28969,395,84829,083,00019,055,00094,797,824
3Apr 24, 2026 22:315,29466,200,98230,112,00018,067,00094,797,824
4Apr 24, 2026 22:315,29671,724,63727,113,00021,088,00094,801,920
5Apr 24, 2026 22:315,30967,745,38128,182,00020,130,00094,801,920
6Apr 24, 2026 22:315,31567,706,73529,224,00019,146,00094,801,920
7Apr 24, 2026 22:315,31564,638,10830,232,00018,139,00094,834,688
8Apr 24, 2026 22:315,32567,701,66227,260,00021,202,00094,789,632
9Apr 24, 2026 22:315,36566,156,03028,899,00019,930,00094,801,920