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 MartinScore: 3,947Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 10, 2026 22:483,90865,829,70216,794,00018,770,00094,666,752
2Mar 10, 2026 22:473,91865,341,84916,838,00018,819,00094,552,064
3Mar 10, 2026 22:483,91961,232,71716,841,00018,823,00094,552,064
4Mar 10, 2026 22:473,92962,852,22216,886,00018,872,00094,662,656
5Mar 10, 2026 22:483,93762,104,84117,912,00017,912,00094,552,064
6Mar 10, 2026 22:473,93862,687,45617,917,00017,917,00094,552,064
7Mar 10, 2026 22:473,94067,271,79717,927,00017,927,00094,670,848
8Mar 10, 2026 22:483,94362,212,46616,942,00018,936,00094,552,064
9Mar 10, 2026 22:473,94462,089,45217,947,00017,947,00094,552,064
10Mar 10, 2026 22:473,94766,484,23918,955,00016,960,00094,638,080
11Mar 10, 2026 22:483,94759,572,98218,959,00016,963,00094,552,064
12Mar 10, 2026 22:483,95362,685,49116,985,00018,984,00094,552,064
13Mar 10, 2026 22:473,95462,186,15318,990,00016,991,00094,662,656
14Mar 10, 2026 22:483,95556,644,02018,993,00016,993,00094,674,944
15Mar 10, 2026 22:473,95658,856,20217,002,00019,002,00094,543,872
16Mar 10, 2026 22:483,96460,424,50919,039,00017,035,00094,552,064
17Mar 10, 2026 22:473,97863,625,82419,104,00017,093,00094,552,064
18Mar 10, 2026 22:483,99163,525,29819,167,00017,149,00094,552,064