尝试运行JSON.Parse
时出现以下错误{"documents": [{"documentId": "1","fileExtension": "pdf","name": "Top_Level_Agreement.pdf"}]},{"Email Subject":"DocuSign-Top Level Agreement"},{"Envelope Reciepients":[{"carbonCopies":[{"carbonCopy1":[{"email":"zabie@toplevelstaging.com","name":"Zabie Sahial","recipientId":"2"}]{"signers":[+
SyntaxError:意外的令牌,位于位置93的JSON中 at Object.parse(native) 在对象。 (/家/ toplevelstaging /顶层
这是我的代码
var Envelope_Definition = [];
Envelope_Definition[0] = '{"documents": ['+
'{"documentId": "1","fileExtension": "pdf","name": "Top_Level_Agreement.pdf"}]}';
Envelope_Definition[1] = '{"Email Subject":"DocuSign-Top Level Agreement"}';
Envelope_Definition[2] = '{"Envelope Reciepients":['+
'{"carbonCopies":['+
'{"carbonCopy1":['+
'{"email":"zabie@toplevelstaging.com","name":"Zabie Sahial","recipientId":"2"}]'+
'{"signers":[+'
'{"signer1":['+
'{"EnvelopeTabs":['+
'{""}]"}]}]}}]}';
data = JSON.parse(Envelope_Definition);
console.log(data);
答案 0 :(得分:0)
你需要的只是
var data = {"documents": [
{"documentId": "1","fileExtension": "pdf","name": "Top_Level_Agreement.pdf"}]},
{"Email Subject":"DocuSign-Top Level Agreement"},
{"Envelope Reciepients":[
{"carbonCopies":[{"email":"zabie@toplevelstaging.com","name":"Zabie Sahial","recipientId":"2"}],
{"signers":[{"signer1":[{"EnvelopeTabs":[{}]}]}]}}]};
(或类似的东西)。 JavaScript natively 通过文字语法支持对象定义。这就是JSON的来源;这就是为什么它被称为“JavaScript Object Notation”。