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 listDec 24, 2025 01:21Josu San MartinJosu San MartinScore: 20,839Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 24, 2025 01:2120,647209,939,752167,900,00019,988,00094,625,792
2Dec 24, 2025 01:2120,661215,788,448163,017,00025,002,00094,789,632
3Dec 24, 2025 01:2120,696218,892,339164,418,00023,915,00094,773,248
4Dec 24, 2025 01:2120,725228,365,903166,645,00021,953,00094,797,824
5Dec 24, 2025 01:2120,839215,666,099167,681,00021,958,00094,789,632
6Dec 24, 2025 01:2120,900214,879,663163,161,00027,026,00094,576,640
7Dec 24, 2025 01:2120,952222,319,784163,709,00026,952,00094,785,536
8Dec 24, 2025 01:2121,834227,543,189164,745,00033,947,00094,789,632
9Dec 24, 2025 01:2122,476231,966,405168,618,00035,918,00094,801,920