我寫的東西,而前一個插件,它可以幫助你讓你的頭在你身邊需要做什麼:
private String viewTicketField(String jiraserver, String jirauser,String jirapass, String url, String customField) {
if (url.endsWith('undefined')) {
return
}
String output=''
try {
HBuilder hBuilder=new HBuilder()
RESTClient http = hBuilder.httpConn(jiraserver, jirauser, jirapass,httpConnTimeOut,httpSockTimeOut)
http.request(Method.GET) { req ->
uri.path = url
response.success = { resp, json ->
log.info "Process URL Success! ${resp.status} "
def result=JSON.parse(json.toString())
if (result.fields."customfield_${customField}") {
output=result.fields."customfield_${customField}"
}
}
response.failure = { resp ->
log.error "Process URL failed with status ${resp.status}"
}
}
}
catch (HttpResponseException e) {
log.error "Failed error: $e.statusCode"
}
return output
}
HBuilder類可以在src
找到您已連接後回來的JSON響應,你再分析每一行
您創建一個新的域類
String url
String datetime
String app_id
String ticket_url
...等等,這是從上面的URL整個條目,以便爲你實際需要放於域類的字符串,然後分析每個迭代上面代碼中的每個關鍵
{"id":13926481,"url":"http://www.bandsintown.com/event/13926481?app_id=FYP","datetime":"2017-02-23T17:00:00","ticket_url":"http://www.bandsintown.com/event/13926481/buy_tickets?app_id=FYP\u0026came_from=233","artists":[{"name":"Rackhouse Pilfer","url":"http://www.bandsintown.com/RackhousePilfer","mbid":null}],"venue":{"id":3334537,"url":"http://www.bandsintown.com/venue/3334537","name":"Convention Centre","city":"Dublin","region":"07","country":"Ireland","latitude":53.3500292,"longitude":-6.2385286},"ticket_status":"unavailable","on_sale_datetime":null
似乎是一個**寬泛的問題。 – Mistalis
似乎是重複的:http://stackoverflow.com/questions/35041851/inserting-json-object-into-mysql-table-with-angular-php –
使用'JSON.stringify(result);'並插入這個字符串在你的數據庫在各自的列。當閱讀使用'JSON.parse(jsonstring):' –