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 listApr 8, 2026 12:31olliecrowolliecrowScore: 6,764Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 8, 2026 12:506,73987,474,62545,238,00016,084,00094,552,064
2Apr 9, 2026 13:306,74088,459,21642,228,00019,103,00094,666,752
3Apr 8, 2026 12:336,75084,799,28743,297,00018,124,00094,683,136
4Apr 8, 2026 12:516,75088,257,55644,307,00017,118,00094,679,040
5Apr 8, 2026 12:456,75090,987,49344,304,00017,117,00094,683,136
6Apr 8, 2026 12:336,75187,799,71247,332,00014,099,00094,552,064
7Apr 9, 2026 13:306,75590,850,82543,333,00018,139,00094,683,136
8Apr 8, 2026 12:506,75892,935,50746,373,00015,121,00094,552,064
9Apr 8, 2026 12:336,76292,994,28545,391,00016,139,00094,552,064
10Apr 8, 2026 12:426,76387,814,71244,389,00017,150,00094,552,064
11Apr 8, 2026 12:516,76489,522,09647,423,00014,126,00094,679,040
12Apr 8, 2026 12:426,76991,488,16745,440,00016,156,00094,679,040
13Apr 8, 2026 12:426,77585,077,63143,754,00017,899,00094,683,136
14Apr 8, 2026 12:506,77886,814,55942,780,00018,902,00094,670,848
15Apr 8, 2026 12:456,78193,714,79244,789,00016,920,00094,670,848
16Apr 8, 2026 12:316,78194,920,83246,775,00014,928,00094,679,040
17Apr 9, 2026 13:306,78392,961,35144,803,00016,925,00094,670,848
18Apr 8, 2026 12:516,78393,852,10945,799,00015,930,00094,674,944
19Apr 8, 2026 12:316,78383,870,73543,804,00017,920,00094,547,968
20Apr 8, 2026 12:316,79087,280,33445,845,00015,946,00094,797,824
21Apr 8, 2026 12:456,79686,625,38043,890,00017,955,00094,674,944