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 GarmierScore: 9,834Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 16, 2026 14:409,812110,458,67772,234,00017,055,00094,564,352
2Mar 16, 2026 14:409,822116,428,58373,309,00016,067,00094,793,728
3Mar 16, 2026 14:409,830118,449,59173,375,00016,082,00094,793,728
4Mar 16, 2026 14:409,832116,197,72770,374,00019,101,00094,539,776
5Mar 16, 2026 14:409,834114,834,08277,420,00012,065,00094,797,824
6Mar 16, 2026 14:409,843114,363,46975,483,00014,090,00094,793,728
7Mar 16, 2026 14:409,880115,305,62177,917,00011,987,00094,564,352
8Mar 16, 2026 14:409,880116,387,09880,917,0008,990,00094,543,872
9Mar 16, 2026 14:409,883119,452,33781,938,0007,994,00094,564,352