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 16, 2026 10:55Dominique GarmierDominique GarmierError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 18, 2026 01:30Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 18, 2026 01:370294,152,550252,759,00031,006,000126,873,600diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Sep 18, 2026 01:370293,861,825253,294,00030,115,000126,246,912diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Sep 18, 2026 01:370294,603,645253,446,00029,883,000126,414,848diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Mar 16, 2026 10:5512,308134,495,71393,003,00019,000,00094,564,352
5Mar 16, 2026 10:5512,335140,042,56495,212,00017,038,00094,564,352
6Mar 16, 2026 10:5512,365139,931,79694,598,00017,923,00094,556,160
7Mar 16, 2026 10:5512,369140,665,94592,634,00019,921,00094,556,160
8Mar 16, 2026 10:5512,418138,046,17295,003,00018,000,00094,691,328
9Mar 16, 2026 10:5512,483139,804,13097,653,00015,943,00094,564,352
10Mar 16, 2026 10:5512,524141,429,19994,975,00018,995,00094,564,352
11Mar 16, 2026 10:5512,636137,323,58695,987,00018,997,00094,564,352
12Mar 16, 2026 10:5512,657139,208,02597,149,00018,027,00094,539,776