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 listJan 18, 2026 05:35Josu San MartinJosu San MartinScore: 7,006Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 18, 2026 05:306,92887,380,08641,027,00022,014,00094,552,064
2Jan 18, 2026 05:306,95587,861,60942,196,00021,098,00094,666,752
3Jan 18, 2026 05:306,95691,277,61542,201,00021,100,00094,670,848
4Jan 18, 2026 05:356,96585,160,81443,261,00020,121,00094,552,064
5Jan 18, 2026 05:356,96686,283,78142,262,00021,131,00094,666,752
6Jan 18, 2026 05:306,97394,593,98942,302,00021,151,00094,674,944
7Jan 18, 2026 05:306,98493,396,76545,398,00018,159,00094,662,656
8Jan 18, 2026 05:306,99791,048,41841,788,00021,889,00094,666,752
9Jan 18, 2026 05:307,00586,631,04641,834,00021,913,00094,547,968
10Jan 18, 2026 05:357,00690,365,08642,835,00020,919,00094,674,944
11Jan 18, 2026 05:357,02084,746,85938,928,00024,954,00094,552,064
12Jan 18, 2026 05:357,02987,826,31041,977,00021,988,00094,609,408
13Jan 18, 2026 05:357,04787,193,79742,084,00022,044,00094,691,328
14Jan 18, 2026 05:357,14790,428,43642,023,00023,012,00094,670,848
15Jan 18, 2026 05:357,20386,642,63540,721,00024,830,00094,576,640
16Jan 18, 2026 05:307,21795,965,15742,787,00022,886,00094,552,064
17Jan 18, 2026 05:357,27288,990,21641,110,00025,067,00094,670,848
18Jan 18, 2026 05:307,29591,121,11141,614,00024,770,00094,756,864