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 25, 2026 20:56Dominique GarmierDominique GarmierScore: 155,924Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 25, 2026 22:35153,5251,419,990,4491,328,121,00068,954,00094,760,960
2Mar 22, 2026 20:10153,6381,426,173,0791,325,149,00072,953,00094,625,792
3Mar 25, 2026 22:14153,8231,424,275,1081,323,859,00075,934,00094,617,600
4Mar 25, 2026 17:16155,7651,441,769,8831,345,486,00071,972,00094,785,536
5Mar 22, 2026 09:27155,8351,440,916,5061,343,148,00074,952,00094,625,792
6Mar 22, 2026 09:27155,8491,439,130,1001,347,262,00070,961,00094,617,600
7Mar 25, 2026 17:16155,8581,440,373,5591,353,341,00064,968,00094,658,560
8Mar 25, 2026 22:35155,8731,448,203,3531,344,477,00073,971,00094,613,504
9Mar 25, 2026 22:14155,8931,445,821,4711,349,644,00068,981,00094,752,768
10Mar 25, 2026 22:35155,9221,447,720,7501,350,947,00067,947,00094,699,520
11Mar 25, 2026 22:14155,9241,448,350,6401,350,961,00067,947,00094,617,600
12Mar 25, 2026 17:16155,9651,445,170,8801,343,325,00075,961,00094,609,408
13Mar 25, 2026 17:08156,0631,445,491,0461,345,215,00074,956,00094,617,600
14Mar 22, 2026 20:10156,0951,446,342,6881,348,491,00071,972,00094,621,696
15Mar 25, 2026 17:08156,1211,448,261,9001,344,767,00075,930,00094,666,752
16Mar 22, 2026 20:10156,1401,445,405,1021,342,934,00077,938,00094,613,504
17Mar 25, 2026 17:08156,2701,447,193,4921,348,110,00073,951,00094,765,056
18Mar 22, 2026 09:27156,6201,455,260,2321,353,282,00071,961,00094,576,640
19Mar 25, 2026 20:56156,8541,449,603,7331,353,352,00074,019,00094,617,600
20Mar 25, 2026 20:56156,9121,448,004,5861,355,958,00071,944,00094,756,864
21Mar 25, 2026 20:56157,1821,451,955,8281,353,448,00076,911,00094,617,600