2017-05-06 9 views
0

JSONからXMLへのオンラインリソースは豊富ですが、辞書ではなく通常の配列形式である場合に限ります。JSON辞書をXMLに変換するにはどうすればよいですか?

私は何をすべきか知っていますか?私は私のプロジェクトでXMLを使用したいが、私はそれを変換するとき、私はちょうどほとんど使用され、以下の取得:

< 0 KiFRirIKU_I0FIXWj1j =「[対象オブジェクト]」KiQPi-1EiURvD3zK2IY =「[対象オブジェクト]」

どうすればよいですか? JSON辞書の

例は以下の通りです:XML用の

[{ 
    "-KiFRirIKU_I0FIXWj1j": { 
    "category": "1", 
    "id": "-KiFRirIKU_I0FIXWj1j", 
    "image_url": "", 
    "message": "Water leaking out side of it for ages now but it's coming out the bottom now too!", 
    "postcode": "LL53", 
    "reports": "0", 
    "status": "0", 
    "time": "21-04-2017 13:18:25", 
    "title": "Leaking Bath, L12 area!", 
    "user_id": "esO8EE8aoLM3bvKalHNvI9Hv7Ra2" 
    }, 
    "-KiQPi-1EiURvD3zK2IY": { 
    "category": "3", 
    "id": "-KiQPi-1EiURvD3zK2IY", 
    "image_url": "/v0/b/fixee-164914.appspot.com/o/esO8EE8aoLM3bvKalHNvI9Hv7Ra2514653921592.jpg", 
    "message": "How much would it cost a week to keep this in decent shape? Had extortionate quotes and need it done cheap soon!", 
    "postcode": "LE11 3UQ", 
    "reports": "0", 
    "status": "0", 
    "time": "23-04-2017 16:25:23", 
    "title": "Gardener Required!!", 
    "user_id": "esO8EE8aoLM3bvKalHNvI9Hv7Ra2" 
}] 

答えて

0

ルートノードは、あなたのJSONにある場合、ルートノードは、必要とされていますか? 次のようなコンバータを使用してxmlからjsonへの変換を試みてください:http://www.utilities-online.info/xmltojson/ jsonを有効にするにはxmlをどのようにフォーマットする必要があるのか​​分かります。

のでご例えば私が最初にXMLを作成し、その後、JSONに変換:

{ 
    "root": { 
    "KiFRirIKU_I0FIXWj1j": { 
     "category": "1", 
     "id": "-KiFRirIKU_I0FIXWj1j", 
     "message": "Water leaking out side of it for ages now but it's coming out the bottom now too!", 
     "postcode": "LL53", 
     "reports": "0", 
     "status": "0", 
     "time": "21-04-2017 13:18:25", 
     "title": "Leaking Bath, L12 area!", 
     "user_id": "esO8EE8aoLM3bvKalHNvI9Hv7Ra2" 
    }, 
    "KiQPi-1EiURvD3zK2IY": { 
     "category": "1", 
     "id": "-KiFRirIKU_I0FIXWj1j", 
     "message": "Water leaking out side of it for ages now but it's coming out the bottom now too!", 
     "postcode": "LL53", 
     "reports": "0", 
     "status": "0", 
     "time": "21-04-2017 13:18:25", 
     "title": "Leaking Bath, L12 area!", 
     "user_id": "esO8EE8aoLM3bvKalHNvI9Hv7Ra2" 
    } 
    } 
} 

<root> 
    <KiFRirIKU_I0FIXWj1j> 
    <category>1</category> 
    <id>-KiFRirIKU_I0FIXWj1j</id> 
    <image_url></image_url> 
    <message>Water leaking out side of it for ages now but it's coming out the bottom now too!</message> 
    <postcode>LL53</postcode> 
    <reports>0</reports> 
    <status>0</status> 
    <time>21-04-2017 13:18:25</time> 
    <title>Leaking Bath, L12 area!</title> 
    <user_id>esO8EE8aoLM3bvKalHNvI9Hv7Ra2</user_id> 
</KiFRirIKU_I0FIXWj1j> 
<KiQPi-1EiURvD3zK2IY> 
    <category>1</category> 
    <id>-KiFRirIKU_I0FIXWj1j</id> 
    <image_url></image_url> 
    <message>Water leaking out side of it for ages now but it's coming out the bottom now too!</message> 
    <postcode>LL53</postcode> 
    <reports>0</reports> 
    <status>0</status> 
    <time>21-04-2017 13:18:25</time> 
    <title>Leaking Bath, L12 area!</title> 
    <user_id>esO8EE8aoLM3bvKalHNvI9Hv7Ra2</user_id> 
</KiQPi-1EiURvD3zK2IY> 

</root> 

はにつながります

関連する問題