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 listOct 8, 2026 04:51Karthik ReddyKarthik ReddyError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Oct 13, 2026 13:00Andrew Epstein366.10CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 13, 2026 13:010316,688,947296,216,00011,474,000137,383,936diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Oct 13, 2026 13:010316,409,399295,895,00011,514,000136,937,472diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Oct 13, 2026 13:010316,511,349295,896,00011,575,000137,580,544diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Oct 8, 2026 04:562,49633,370,02914,110,0008,608,00092,807,168
5Oct 8, 2026 04:562,50231,800,68214,222,0008,551,00092,893,184
6Oct 8, 2026 04:562,50831,825,26314,234,0008,595,00092,897,280
7Oct 8, 2026 04:562,51031,876,51514,251,0008,591,00092,872,704
8Oct 8, 2026 04:562,51831,929,09114,297,0008,623,00092,905,472
9Oct 8, 2026 04:562,52432,027,34014,488,0008,485,00092,897,280
10Oct 8, 2026 04:562,53231,960,54014,388,0008,659,00092,872,704
11Oct 8, 2026 04:562,53531,989,50314,382,0008,694,00092,901,376
12Oct 8, 2026 04:562,54833,612,62414,520,0008,671,00092,864,512