我正在尝试使用 postmon 获取 json 字符串的请求来应用 json 补丁。问题是我无法将字符串转换为 json,数据是通过变量发布的。每次我这样做
JSON.parse(document);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
SyntaxError: Unexpected token ' in JSON at position 1
Run Code Online (Sandbox Code Playgroud)
我发送的数据如下
{"document":"{'baz': 'qux', 'foo': 'bar'}"}
Run Code Online (Sandbox Code Playgroud)
通过邮递员使用 post 方法。
我正在使用 req.body 来获取发布数据
我正在尝试在 Node Js 中重写以下函数,以生成校验和并验证支付交易,而且我对在 Node Js 中编写代码还很陌生。
我已经从服务提供者那里获得了代码,我需要将其转换为 Node Js。我使用 Express 作为我的后端。
<?php
function generateChecksum($transId,$sellingCurrencyAmount,$accountingCurrencyAmount,$status, $rkey,$key)
{
$str = "$transId|$sellingCurrencyAmount|$accountingCurrencyAmount|$status|$rkey|$key";
$generatedCheckSum = md5($str);
return $generatedCheckSum;
}
function verifyChecksum($paymentTypeId, $transId, $userId, $userType, $transactionType, $invoiceIds, $debitNoteIds, $description, $sellingCurrencyAmount, $accountingCurrencyAmount, $key, $checksum)
{
$str = "$paymentTypeId|$transId|$userId|$userType|$transactionType|$invoiceIds|$debitNoteIds|$description|$sellingCurrencyAmount|$accountingCurrencyAmount|$key";
$generatedCheckSum = md5($str);
// echo $str."<BR>";
// echo "Generated CheckSum: ".$generatedCheckSum."<BR>";
// echo "Received Checksum: ".$checksum."<BR>";
if($generatedCheckSum == $checksum)
return true ;
else
return false ;
}
?>
Run Code Online (Sandbox Code Playgroud)
如何在 Javascript 中编写以下代码并传递参数。