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 01:12Josu San MartinJosu San MartinScore: 4,146Success
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:594,10159,353,82218,157,00019,166,00094,674,944
2Mar 10, 2026 00:594,10260,048,10918,159,00019,168,00094,547,968
3Mar 10, 2026 00:594,10359,924,68418,162,00019,172,00094,547,968
4Mar 10, 2026 01:124,10663,770,93120,196,00017,167,00094,662,656
5Mar 10, 2026 00:594,12662,561,81120,748,00016,796,00094,547,968
6Mar 10, 2026 00:594,13464,594,00418,810,00018,810,00094,568,448
7Mar 10, 2026 00:594,14660,256,79718,866,00018,866,00094,670,848
8Mar 10, 2026 00:594,14768,131,61020,854,00016,882,00094,547,968
9Mar 10, 2026 00:594,14865,492,27619,866,00017,880,00094,674,944
10Mar 10, 2026 01:124,16061,843,80620,920,00016,935,00094,683,136
11Mar 10, 2026 01:124,17162,470,51419,975,00017,977,00094,547,968
12Mar 10, 2026 00:594,18059,422,45220,020,00018,018,00094,547,968