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 11:01Dominique GarmierDominique GarmierScore: 12,118Success
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 11:0112,074138,779,63293,889,00015,981,00094,539,776
2Mar 16, 2026 11:0112,083142,031,22392,965,00016,993,00094,556,160
3Mar 16, 2026 11:0112,095137,685,73195,054,00015,008,00094,650,368
4Mar 16, 2026 11:0112,095139,935,12992,058,00018,011,00094,543,872
5Mar 16, 2026 11:0112,118136,418,46195,238,00015,037,00094,543,872
6Mar 16, 2026 11:0112,123136,258,00192,266,00018,052,00094,797,824
7Mar 16, 2026 11:0112,148137,880,98493,613,00016,930,00094,543,872
8Mar 16, 2026 11:0112,174134,650,47491,819,00018,962,00094,793,728
9Mar 16, 2026 11:0112,625145,909,37896,904,00017,982,00094,785,536