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 17, 2026 09:49Dominique GarmierDominique GarmierScore: 7,768Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 17, 2026 09:497,73495,062,62554,519,00015,860,00094,662,656
2Mar 17, 2026 09:497,74195,587,61055,348,00015,095,00094,543,872
3Mar 17, 2026 09:497,765102,363,30052,746,00017,913,00094,564,352
4Mar 17, 2026 09:497,76698,330,14953,750,00016,921,00094,564,352
5Mar 17, 2026 09:497,76896,812,87853,525,00017,168,00094,564,352
6Mar 17, 2026 09:497,772102,559,85453,788,00016,933,00094,539,776
7Mar 17, 2026 09:497,77396,163,87250,811,00019,926,00094,543,872
8Mar 17, 2026 09:497,77798,626,91453,824,00016,944,00094,564,352
9Mar 17, 2026 09:497,80594,394,82652,018,00019,006,00094,539,776