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 listJan 18, 2026 07:08Josu San MartinJosu San MartinScore: 5,151Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 18, 2026 07:005,11969,354,05712,884,00033,699,00094,654,464
2Jan 18, 2026 07:085,11968,406,49815,858,00030,725,00094,662,656
3Jan 18, 2026 07:085,12570,216,44617,861,00028,777,00094,662,656
4Jan 18, 2026 07:085,12777,484,69716,876,00029,781,00094,674,944
5Jan 18, 2026 07:005,14669,836,91720,923,00025,905,00094,547,968
6Jan 18, 2026 07:085,14667,519,69020,925,00025,908,00094,785,536
7Jan 18, 2026 07:005,14770,355,02715,944,00030,892,00094,547,968
8Jan 18, 2026 07:005,14868,546,77121,928,00024,918,00094,670,848
9Jan 18, 2026 07:005,14974,987,07423,927,00022,930,00094,547,968
10Jan 18, 2026 07:085,15172,521,14823,938,00022,940,00094,666,752
11Jan 18, 2026 07:005,15772,451,49323,962,00022,963,00094,785,536
12Jan 18, 2026 07:085,15769,041,28924,964,00021,968,00094,670,848
13Jan 18, 2026 07:005,15973,935,22325,971,00020,977,00094,662,656
14Jan 18, 2026 07:085,16874,333,00825,017,00022,015,00094,547,968
15Jan 18, 2026 07:085,17770,988,04529,069,00018,042,00094,662,656
16Jan 18, 2026 07:005,19575,203,28328,164,00019,111,00094,674,944
17Jan 18, 2026 07:005,21174,759,94530,268,00017,152,00094,547,968
18Jan 18, 2026 07:085,23769,573,61522,834,00024,820,00094,584,832