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 04:10olliecrowolliecrowScore: 5,634Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 16, 2026 16:194,34764,688,96921,756,00017,800,00094,658,560
2Apr 16, 2026 16:194,35069,832,12122,763,00016,824,00094,760,960
3Apr 16, 2026 16:194,36766,191,89722,853,00016,891,00094,654,464
4Apr 16, 2026 16:264,37164,825,56420,882,00018,894,00094,769,152
5Apr 16, 2026 16:264,38964,251,83422,968,00016,976,00094,765,056
6Apr 16, 2026 16:224,39762,999,78723,008,00017,006,00094,658,560
7Apr 16, 2026 16:124,41064,697,11522,070,00018,057,00094,642,176
8Apr 16, 2026 16:224,41462,950,54124,100,00016,067,00094,658,560
9Apr 16, 2026 16:224,44871,776,39724,284,00016,189,00094,711,808
10Apr 16, 2026 16:264,46369,387,69119,810,00020,800,00094,642,176
11Apr 16, 2026 16:124,55967,565,94419,226,00022,262,00094,773,248
12Apr 16, 2026 17:054,61368,583,96826,984,00014,991,00094,658,560
13Apr 16, 2026 16:124,61765,812,00924,009,00018,006,00094,781,440
14Apr 16, 2026 17:054,61970,817,50426,023,00016,014,00094,658,560
15Apr 16, 2026 17:054,63763,653,91825,115,00017,078,00094,658,560
16Apr 16, 2026 19:594,85469,304,43430,117,00014,054,00094,642,176
17Apr 16, 2026 19:594,86168,599,36226,141,00018,097,00094,658,560
18Apr 16, 2026 19:594,91170,150,11127,808,00016,883,00094,769,152
19Apr 16, 2026 17:175,36773,272,31531,894,00016,944,00094,658,560
20Apr 16, 2026 17:175,37670,734,14728,952,00019,967,00094,642,176
21Apr 16, 2026 17:175,38472,055,39328,999,00019,999,00094,658,560
22Apr 16, 2026 16:575,51177,820,15029,086,00021,062,00094,609,408
23Apr 16, 2026 16:575,51475,152,80331,111,00019,068,00094,621,696
24Apr 16, 2026 16:575,53080,711,29032,208,00018,117,00094,773,248
25Apr 16, 2026 17:235,63474,044,94532,170,00019,101,00094,707,712
26Apr 16, 2026 17:235,63573,791,81032,176,00019,105,00094,621,696
27Apr 16, 2026 17:235,65982,570,59834,329,00017,164,00094,650,368
28Apr 16, 2026 19:466,66090,012,47541,728,00018,877,00094,781,440
29Apr 16, 2026 19:466,66183,659,20742,732,00017,887,00094,769,152
30Apr 16, 2026 19:466,70885,182,23643,029,00018,012,00094,760,960
31Mar 21, 2026 12:067,87599,353,18754,744,00016,921,00094,658,560
32Mar 21, 2026 12:067,903102,648,02456,936,00014,983,00094,777,344
33Mar 21, 2026 12:067,96998,402,35655,397,00017,122,00094,638,080
34Mar 20, 2026 05:528,611107,572,40661,285,00017,079,00094,658,560
35Mar 20, 2026 05:528,647105,400,89162,752,00015,937,00094,617,600
36Mar 20, 2026 05:528,656103,792,96262,814,00015,952,00094,642,176
37Apr 7, 2026 00:038,887103,822,44564,900,00015,975,00094,658,560
38Mar 21, 2026 04:108,929112,054,33962,197,00019,060,00094,621,696
39Apr 7, 2026 00:038,932106,240,49662,218,00019,066,00094,785,536
40Mar 20, 2026 05:588,939107,598,30362,261,00019,080,00094,773,248
41Apr 7, 2026 05:168,947106,504,28360,313,00021,109,00094,658,560
42Apr 7, 2026 05:168,952110,139,19864,578,00016,889,00094,773,248
43Mar 20, 2026 05:588,970105,369,09364,708,00016,923,00094,773,248
44Apr 7, 2026 00:038,977118,243,10663,758,00017,932,00094,744,576
45Apr 7, 2026 05:168,977108,765,26965,749,00015,939,00094,642,176
46Mar 20, 2026 05:588,990110,844,38563,851,00017,958,00094,765,056
47Mar 21, 2026 04:109,010108,815,62764,992,00016,998,00094,638,080
48Mar 21, 2026 04:109,145122,365,54463,409,00019,815,00094,650,368