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 listSep 17, 2026 16:14Victor MerckléVictor MerckléScore: 226,380Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 16:27225,2042,059,444,1042,003,784,00045,579,00094,420,992stderr
2Sep 17, 2026 16:27225,9942,067,222,5532,011,351,00045,203,00094,425,088stderr
3Sep 17, 2026 16:27226,1912,068,775,1752,012,629,00045,716,00094,425,088stderr
4Sep 17, 2026 16:27226,3062,069,845,4482,009,019,00050,374,00094,425,088stderr
5Sep 17, 2026 16:27226,3802,070,426,4472,012,333,00047,730,00094,425,088stderr
6Sep 17, 2026 16:27226,5372,071,837,8292,014,231,00047,262,00094,425,088stderr
7Sep 17, 2026 16:27226,9532,086,254,4852,015,647,00049,632,00094,425,088stderr
8Sep 17, 2026 16:27227,1882,078,155,5402,021,079,00046,339,00094,420,992stderr
9Sep 17, 2026 16:27227,5512,091,461,1202,024,385,00046,333,00094,425,088stderr