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 10, 2026 00:56Josu San MartinJosu San MartinScore: 4,126Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 10, 2026 00:564,10263,595,66517,152,00020,179,00094,683,136
2Mar 10, 2026 00:564,11160,629,35218,201,00019,212,00094,683,136
3Mar 10, 2026 00:564,11261,478,52917,193,00020,227,00094,547,968
4Mar 10, 2026 00:564,12366,665,68821,723,00015,799,00094,547,968
5Mar 10, 2026 00:564,12666,528,75121,311,00016,237,00094,547,968
6Mar 10, 2026 00:564,12964,181,43219,778,00017,800,00094,547,968
7Mar 10, 2026 00:564,13162,585,36217,808,00019,786,00094,793,728
8Mar 10, 2026 00:564,14565,591,01621,837,00015,881,00094,674,944
9Mar 10, 2026 00:564,15663,044,38020,900,00016,919,00094,666,752