STRING 轉爲 JSON
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.51</version> </dependency> import com.alibaba.fastjson.JSON val json=JSON.parseObject(""" { "foo": { "bar": 10 }} """) println(json)
XML 轉爲 JSON格式
<dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20140107</version> </dependency> import org.json.XML val xml = "<root> <person> <name>Jones</name> <age>23</age> <occupation>Consultant</occupation> </person></root>" val toJson = XML.toJSONObject(xml) println(toJson)