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 listJun 21, 2025 21:10Aniruddha DebAniruddha DebScore: 3,167Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 21, 2025 21:083,14159,063,39618,728,0009,857,00094,658,560
2Jun 21, 2025 20:513,14654,596,50819,744,0008,885,00094,388,224
3Jun 21, 2025 20:513,14851,790,01319,759,0008,891,00094,392,320
4Jun 21, 2025 20:513,15464,470,84518,804,0009,896,00094,375,936
5Jun 21, 2025 21:113,15556,139,39119,800,0008,910,00094,482,432
6Jun 21, 2025 21:083,15655,028,50418,818,0009,904,00094,412,800
7Jun 21, 2025 20:513,15752,262,23420,518,0008,207,00094,384,128
8Jun 21, 2025 21:083,15858,073,64018,826,0009,908,00094,380,032
9Jun 21, 2025 21:083,16055,370,55918,843,0009,917,00094,412,800
10Jun 21, 2025 21:083,16151,007,89218,846,0009,919,00094,330,880
11Jun 21, 2025 21:113,16457,188,40719,856,0008,935,00094,375,936
12Jun 21, 2025 21:083,16552,615,46919,863,0008,938,00094,334,976
13Jun 21, 2025 20:513,16753,683,83218,884,0009,939,00094,412,800
14Jun 21, 2025 21:103,16850,477,17319,563,0009,267,00094,384,128
15Jun 21, 2025 21:083,16956,011,17418,896,0009,945,00094,597,120
16Jun 21, 2025 21:103,17050,503,30817,903,00010,941,00094,429,184
17Jun 21, 2025 20:513,17152,593,73823,703,0005,152,00094,638,080
18Jun 21, 2025 20:513,17552,020,78318,933,0009,964,00094,400,512
19Jun 21, 2025 21:083,17552,837,99318,930,0009,963,00094,363,648
20Jun 21, 2025 21:083,18152,205,14124,951,0003,992,00094,609,408
21Jun 21, 2025 20:513,18453,086,09920,983,0007,993,00094,388,224
22Jun 21, 2025 20:513,18456,957,22422,979,0005,994,00094,580,736
23Jun 21, 2025 21:103,18557,885,54519,989,0008,995,00094,658,560
24Jun 21, 2025 21:113,19758,453,99418,055,00011,034,00094,588,928