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:32Dominique GarmierDominique GarmierScore: 5,488Success
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:325,42977,799,64327,668,00021,739,00094,797,824
2Mar 30, 2026 17:325,47176,181,19027,882,00021,907,00094,584,832
3Mar 30, 2026 17:325,48373,865,06426,945,00022,953,00094,801,920
4Mar 30, 2026 17:325,48580,611,35726,951,00022,958,00094,568,448
5Mar 30, 2026 17:325,48878,816,53326,969,00022,973,00094,797,824
6Mar 30, 2026 17:325,49575,049,35229,005,00021,003,00094,797,824
7Mar 30, 2026 17:325,50277,123,87628,040,00022,031,00094,543,872
8Mar 30, 2026 17:325,58080,341,07429,872,00020,910,00094,568,448
9Mar 30, 2026 17:325,69275,341,14027,892,00023,908,00094,801,920