V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cailangwei
V2EX  ›  Java

关于如何构造json问题

  •  
  •   cailangwei · 2012-09-27 10:59:16 +08:00 · 3775 次点击
    这是一个创建于 4201 天前的主题,其中的信息可能已经有所发展或是发生改变。
    {"playlist":
    [
    {
    "0": {
    "src":"junk/paniq.mp3",
    "type":"audio/mp3"
    },
    "1": {
    "src":"junk/paniq.ogg",
    "type":"audio/ogg"
    },
    "config": {
    "title": "An Educated Simpleton - Copy One",
    "poster": "junk/cover.jpg"
    }
    }
    ]
    }
    如何构造这么一个json结构?是不是用map、list之类生成它的结构?
    6 条回复    1970-01-01 08:00:00 +08:00
    udonmai
        1
    udonmai  
       2012-09-27 11:51:09 +08:00
    具体语言具体分析。。。不过一般也就是map,这个map不特指任何特定编程语言的特定数据结构
    khotyn
        2
    khotyn  
       2012-09-27 12:42:59 +08:00
    Java 生成 JSON 的话应该有各种类库可以把对象转换成 JSON 字符串吧,你可以看看 FastJSON 这个类库:https://github.com/AlibabaTech/fastjson/wiki
    forest520
        3
    forest520  
       2012-09-27 12:46:14 +08:00
    这个我用过,google开源的,还不错:http://code.google.com/p/google-gson/
    holmesabc
        4
    holmesabc  
       2012-09-27 12:54:43 +08:00
    感觉最简单的就是gson了,google的东西好用

    可以直接将一个对象生成json,或者将json直接解析成一个特定类。
    catfan
        5
    catfan  
       2012-09-27 13:43:01 +08:00
    直接用Qatrix里面的$json.encode()便可

    http://qatrix.com/api/json.encode
    twm
        6
    twm  
       2012-09-27 13:52:13 +08:00
    gson+1
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5374 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 07:30 · PVG 15:30 · LAX 00:30 · JFK 03:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.