729334218
V2EX  ›  问与答

暂时没有接口,我需要做一个假数据(一个.json 格式的文档)添加到应用里首先进行本地测试,但是这个文档该怎样建立呢

  •  
  •   729334218 · May 9, 2014 · 6763 views
    This topic created in 4452 days ago, the information mentioned may be changed or developed.
    谢谢大家!
    8 replies    2014-05-10 08:28:42 +08:00
    mingzhi
        1
    mingzhi  
       May 9, 2014
    touch test.json
    jsonline
        2
    jsonline  
       May 9, 2014
    context 没有交待清楚吧。
    fanzeyi
        3
    fanzeyi  
       May 9, 2014
    victor
        4
    victor  
       May 9, 2014
    我的 railstips 的 workflow 也有一样的需求,所以我在 github 上面搞了一个文件

    https://github.com/wjp2013/railstips/blob/master/data.json

    附 workflow 的网址 https://github.com/wjp2013/alfred2-workflows
    powerfj
        5
    powerfj  
       May 10, 2014
    fiddler
    ipconfiger
        6
    ipconfiger  
       May 10, 2014
    ezreal
        7
    ezreal  
       May 10, 2014
    anheiyouxia
        8
    anheiyouxia  
       May 10, 2014
    我的方法比较简单比较笨,直接用JS的方法,你可以用Nodejs运行也可以在浏览器的Console下运行:
    var jsonObj = new Object();
    jsonObj['name'] = 'anheiyouxia' ;
    jsonObj['mail'] = '[email protected]' ;

    var child = new Object();
    child['a'] = 'aaa' ;
    jsonObj['child'] = child ;

    JSON.stringify(jsonObj) ;
    //"{"name":"anheiyouxia","mail":"[email protected]","child":{"a":"aaa"}}"
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1042 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 18:49 · PVG 02:49 · LAX 11:49 · JFK 14:49
    ♥ Do have faith in what you're doing.