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 14:40Dominique GarmierDominique GarmierError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 18, 2026 00:39Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 18, 2026 00:470291,121,066249,653,00030,605,000126,590,976diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Sep 18, 2026 00:470288,850,710247,079,00030,516,000126,345,216diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Sep 18, 2026 00:470288,220,510247,685,00030,048,000126,779,392diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Mar 16, 2026 14:409,812110,458,67772,234,00017,055,00094,564,352
5Mar 16, 2026 14:409,822116,428,58373,309,00016,067,00094,793,728
6Mar 16, 2026 14:409,830118,449,59173,375,00016,082,00094,793,728
7Mar 16, 2026 14:409,832116,197,72770,374,00019,101,00094,539,776
8Mar 16, 2026 14:409,834114,834,08277,420,00012,065,00094,797,824
9Mar 16, 2026 14:409,843114,363,46975,483,00014,090,00094,793,728
10Mar 16, 2026 14:409,880115,305,62177,917,00011,987,00094,564,352
11Mar 16, 2026 14:409,880116,387,09880,917,0008,990,00094,543,872
12Mar 16, 2026 14:409,883119,452,33781,938,0007,994,00094,564,352