我需要使用json构建器生成一个json,我正在这样做
class DynamicJson{
def effective_date
}
json = new DynamicJson(effective_date:["year":'2012',"month":'8',"day":'2',
"hour":'22',"minute":'12',"second":'12',"millis":'0',"time_zone":'UTC'])
正在制作
{"effective_date":{"year": 2012,"month":8,"day":2,"hour":22,"minute":12,"second":12,
"millis":0,"time_zone":"UTC"}}
但我想要的输出是:
{"effective_date":{"year": 2012,"month": 8,"day": 2,"hour": 22,
"minute": 19, "second": 12,"millis": 0,"time_zone":{"id": "UTC"}}
我如何生成
"time_zone":{"id": "UTC"}?
答案 0 :(得分:1)
将构造函数更改为:
json = new DynamicJson(effective_date:[
year:'2012',
month:'8',
day:'2',
hour:'22',
minute:'12',
second:'12',
millis:'0',
time_zone:[id:'UTC']
])
答案 1 :(得分:0)
试试这个.. json = new DynamicJson(effective_date:[“year”:'2012',“month”:'8',“day”:'2', “小时”: '22', “分”: '12', “第二”: '12', “米利斯”: '0', “的time_zone”:[ “ID”: 'UTC']])