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 21, 2026 14:53Josu San MartinJosu San MartinScore: 3,933Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 21, 2026 14:533,89161,829,44621,245,00014,163,00094,547,968
2Mar 21, 2026 14:533,89761,001,49217,224,00018,237,00094,547,968
3Mar 21, 2026 14:533,91467,275,13317,808,00017,808,00094,674,944
4Mar 21, 2026 14:533,93164,260,73618,881,00016,893,00094,547,968
5Mar 21, 2026 14:533,93369,488,12318,888,00016,900,00094,662,656
6Mar 21, 2026 14:533,94462,719,79918,942,00016,948,00094,785,536
7Mar 21, 2026 14:533,95557,779,38217,995,00017,995,00094,666,752
8Mar 21, 2026 14:533,95761,820,14218,005,00018,005,00094,662,656
9Mar 21, 2026 14:533,95858,342,30718,009,00018,009,00094,547,968