在talend中将multilevel xml转换为json

时间:2015-04-23 21:56:27

标签: xml json talend

以下是代码:

<labels>
<label><id>1</id><name>Planet E</name><contactinfo>Planet E Communications P.O. Box 27218 Detroit, 48227, USA p: 313.874.8729 f: 313.874.8732 email: info AT Planet-e DOT net
 </contactinfo><profile>Classic Techno label from Detroit, USA. [b]Label owner:[/b] [a=Carl Craig].
</profile><data_quality>Needs Vote</data_quality><urls><url>http://planet-e.net</url><url>http://planetecommunications.bandcamp.com</url><url>http://www.discogs.com/user/planetedetroit</url><url>http://www.facebook.com/planetedetroit</url><url>http://www.flickr.com/photos/planetedetroit</url><url>http://plus.google.com/100841702106447505236</url><url>http://myspace.com/planetecom</url><url>http://myspace.com/planetedetroit</url><url>http://soundcloud.com/planetedetroit</url><url>http://twitter.com/planetedetroit</url><url>http://vimeo.com/user1265384</url><url>http://www.youtube.com/user/planetedetroit</url><url>http://en.wikipedia.org/wiki/Planet_E_Communications</url></urls><sublabels><label>Antidote (4)</label><label>Community Projects</label><label>Guilty Pleasures</label><label>I Ner Zon Sounds</label><label>Planet E Communications, Inc.</label><label>TWPENTY</label></sublabels></label>
 <label><id>2</id><name>Earthtones Recordings</name><contactinfo>Seasons Recordings
2236 Pacific Avenue
Suite D
Costa Mesa, CA  92627

tel: +1.949.574.5255
fax: +1.949.574.0255

email: &lt;a href="mailto:jthinnes@seasonsrecordings.com"&gt;jthinnes@seasonsrecordings.com&lt;/a&gt;
   </contactinfo><profile>California deep house label founded by Jamie Thinnes. Now defunct and continued as [l=Seasons Recordings].</profile> <data_quality>Correct</data_quality><urls><url>http://www.seasonsrecordings.com/</url></urls></label></labels>

我尝试了twritejsonfield,但它并没有保留多级层次结构。请帮忙

1 个答案:

答案 0 :(得分:0)

我使用的是外部库。 Json-lib。我在行之后传递了xml,并将其转换为json并将json保存在一个带有json扩展名的简单文件中。