我有一个Webhook可以接收字符串格式的数据:
"{\"id\":\"2119813016789714851\",\"auth0_id\":\"auth0|5bbef2b54dac115c7a86684b\",\"title\":null,\"first_name\":\"Gary\",\"last_name\":\"Richard\",\"date_of_birth\":\"1994-04-10T00:00:00.000Z\",\"phone\":\"+44123456789\",\"company_id\":\"2119813365948745637\",\"status\":\"NEEDS_REVIEW\",\"email\":\"demo-1@lendflo.com\",\"agree_lendflo\":true,\"agree_authorized\":true,\"delete_director_id\":null,\"mail_change_code\":null,\"postcode\":\"ng72du\",\"address\":\"10 Faraday Road, Nottingham, Nottinghamshire\",\"country\":\"United Kingdom\",\"name\":\"fdsqfdsqfdsq\",\"company_house_no\":\"485245874\",\"main_contact_first_name\":\"Gary\",\"main_contact_last_name\":\"Richard\",\"registered_address\":\"fdsqfdsqfdsq\",\"trading_address\":null,\"website\":null,\"last_year_revenue\":\"123456\",\"registered_address_postcode\":\" LE1 6RP\",\"trading_address_postcode\":null,\"vat_number\":null,\"employee_count\":0,\"primary_user\":\"2119813016789714851\",\"company_status\":\"SIGNUP_INCOMPLETE\",\"companyIndustries\":[{\"sic\":\"62090\",\"label\":\"Other information technology service activities\"},{\"sic\":\"64992\",\"label\":\"Factoring\"}],\"stage\":\"dev\"}"
我需要将该字符串转换为JSON并将其放入数组中,以便可以通过zap的后续操作准备就绪。
我正在尝试使用此代码处理javascript中的代码模块
output = []
var data = JSON.parse(input.data)
output.push(data)
但是我得到一个错误:
We had trouble sending your test through.
You must return a single object or array of objects.
答案 0 :(得分:1)
效果很好,我认为您的input.data
输入不正确
const data = "{\"id\":\"2119813016789714851\",\"auth0_id\":\"auth0|5bbef2b54dac115c7a86684b\",\"title\":null,\"first_name\":\"Gary\",\"last_name\":\"Richard\",\"date_of_birth\":\"1994-04-10T00:00:00.000Z\",\"phone\":\"+44123456789\",\"company_id\":\"2119813365948745637\",\"status\":\"NEEDS_REVIEW\",\"email\":\"demo-1@lendflo.com\",\"agree_lendflo\":true,\"agree_authorized\":true,\"delete_director_id\":null,\"mail_change_code\":null,\"postcode\":\"ng72du\",\"address\":\"10 Faraday Road, Nottingham, Nottinghamshire\",\"country\":\"United Kingdom\",\"name\":\"fdsqfdsqfdsq\",\"company_house_no\":\"485245874\",\"main_contact_first_name\":\"Gary\",\"main_contact_last_name\":\"Richard\",\"registered_address\":\"fdsqfdsqfdsq\",\"trading_address\":null,\"website\":null,\"last_year_revenue\":\"123456\",\"registered_address_postcode\":\" LE1 6RP\",\"trading_address_postcode\":null,\"vat_number\":null,\"employee_count\":0,\"primary_user\":\"2119813016789714851\",\"company_status\":\"SIGNUP_INCOMPLETE\",\"companyIndustries\":[{\"sic\":\"62090\",\"label\":\"Other information technology service activities\"},{\"sic\":\"64992\",\"label\":\"Factoring\"}],\"stage\":\"dev\"}"
const output = []
const json = JSON.parse(data)
output.push(json)
console.log(output)
答案 1 :(得分:1)
Zapier Platform团队的David在这里。
很奇怪!我进行了快速抽查,并按预期进行了挖矿工作:
我使用以下命令发送了此网络挂钩:
vars
我注意到在您的输入中,您的json似乎包裹在另一组字符串中?我再次检查了我的rename_at
确实是一个字符串。也许可以验证您的身份?您还可以稍微简化一下代码:
library(dplyr)
data %>%
rename_at(seq_len(length(names)), ~ names)
这应该有助于您朝正确的方向前进。