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 listJul 1, 2026 22:27A_ShamanA_ShamanScore: 45,681Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 1, 2026 22:3345,419423,084,252383,193,00030,124,000169,893,888
2Jul 1, 2026 22:3345,500423,716,977383,997,00030,057,000171,991,040
3Jul 1, 2026 22:3345,528423,827,325384,021,00030,284,000169,893,888
4Jul 1, 2026 22:3345,664425,046,431385,332,00030,212,000169,893,888
5Jul 1, 2026 22:3345,681425,636,504385,415,00030,288,000169,893,888
6Jul 1, 2026 22:3345,682425,201,646385,594,00030,117,000169,893,888
7Jul 1, 2026 22:3345,765426,452,300386,472,00029,998,000171,991,040
8Jul 1, 2026 22:3345,807426,792,360386,536,00030,311,000169,893,888
9Jul 1, 2026 22:3346,554433,153,984393,502,00030,145,000169,893,888