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 21, 2026 01:20Dominique GarmierDominique GarmierScore: 10,688Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 21, 2026 01:2010,659118,267,46479,999,00016,999,00094,539,776
2Mar 21, 2026 02:1110,663121,791,38077,028,00020,007,00094,556,160
3Mar 16, 2026 11:0610,671119,696,69977,081,00020,021,00094,703,616
4Mar 21, 2026 02:1110,671120,826,24179,085,00018,019,00094,543,872
5Mar 20, 2026 02:4710,675122,157,34879,113,00018,025,00094,797,824
6Mar 16, 2026 11:0610,676125,877,86977,124,00020,032,00094,556,160
7Mar 16, 2026 11:0610,677121,200,81878,127,00019,031,00094,556,160
8Mar 21, 2026 02:1110,680120,667,94879,152,00018,034,00094,564,352
9Mar 16, 2026 11:0610,682118,574,26378,169,00019,041,00094,556,160
10Mar 20, 2026 02:4710,688125,046,50680,212,00017,045,00094,556,160
11Mar 16, 2026 11:0610,695121,326,14579,268,00018,061,00094,543,872
12Mar 16, 2026 11:0610,702124,639,63776,518,00020,868,00094,797,824
13Mar 16, 2026 11:0610,707123,991,02978,349,00019,085,00094,564,352
14Mar 20, 2026 02:4710,708123,115,11981,370,00016,073,00094,556,160
15Mar 16, 2026 11:0610,719121,948,15577,639,00019,907,00094,539,776
16Mar 16, 2026 11:0610,721126,767,84679,639,00017,918,00094,543,872
17Mar 21, 2026 01:2010,756125,089,40176,905,00020,974,00094,543,872
18Mar 21, 2026 01:2010,757127,134,57675,916,00021,975,00094,556,160