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 10, 2026 22:48Josu San MartinJosu San MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 01:11Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 01:12010,522,50501,380,0002,121,728invalid character '\n' in string literal
2Jul 6, 2026 01:12010,475,38701,350,0002,121,728invalid character '\n' in string literal
3Jul 6, 2026 01:12010,401,8001,255,00002,121,728invalid character '\n' in string literal
4Mar 10, 2026 22:483,90865,829,70216,794,00018,770,00094,666,752
5Mar 10, 2026 22:473,91865,341,84916,838,00018,819,00094,552,064
6Mar 10, 2026 22:483,91961,232,71716,841,00018,823,00094,552,064
7Mar 10, 2026 22:473,92962,852,22216,886,00018,872,00094,662,656
8Mar 10, 2026 22:483,93762,104,84117,912,00017,912,00094,552,064
9Mar 10, 2026 22:473,93862,687,45617,917,00017,917,00094,552,064
10Mar 10, 2026 22:473,94067,271,79717,927,00017,927,00094,670,848
11Mar 10, 2026 22:483,94362,212,46616,942,00018,936,00094,552,064
12Mar 10, 2026 22:473,94462,089,45217,947,00017,947,00094,552,064
13Mar 10, 2026 22:473,94766,484,23918,955,00016,960,00094,638,080
14Mar 10, 2026 22:483,94759,572,98218,959,00016,963,00094,552,064
15Mar 10, 2026 22:483,95362,685,49116,985,00018,984,00094,552,064
16Mar 10, 2026 22:473,95462,186,15318,990,00016,991,00094,662,656
17Mar 10, 2026 22:483,95556,644,02018,993,00016,993,00094,674,944
18Mar 10, 2026 22:473,95658,856,20217,002,00019,002,00094,543,872
19Mar 10, 2026 22:483,96460,424,50919,039,00017,035,00094,552,064
20Mar 10, 2026 22:473,97863,625,82419,104,00017,093,00094,552,064
21Mar 10, 2026 22:483,99163,525,29819,167,00017,149,00094,552,064