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 30, 2026 17:36Dominique GarmierDominique GarmierScore: 5,436Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 30, 2026 17:365,39676,688,57123,047,00026,053,00094,789,632
2Mar 30, 2026 17:365,42171,440,64923,154,00026,174,00094,633,984
3Mar 30, 2026 17:365,42874,526,84824,192,00025,200,00094,797,824
4Mar 30, 2026 17:365,43578,042,29521,198,00028,265,00094,785,536
5Mar 30, 2026 17:365,43676,076,72323,221,00026,250,00094,797,824
6Mar 30, 2026 17:365,45277,700,66125,799,00023,814,00094,781,440
7Mar 30, 2026 17:365,45479,824,24920,846,00028,787,00094,789,632
8Mar 30, 2026 17:365,47375,679,46623,908,00025,900,00094,797,824
9Mar 30, 2026 17:365,49276,411,59027,987,00021,990,00094,785,536