【发布时间】:2023-03-10 05:03:01
【问题描述】:
我有一个 JSON 字符串(通过 JAVA 创建)。我可以再次解码(PHP:json_decode)和创建(PHP:json_encode)JSON字符串,但返回不能与原始JSON字符串相同。 hash256 值不返回相同的值。
$Requestbody = "{\"billerid\": \"RELENG\",\"short_name\": \"HOME91\",
\"authenticators\": [{\"parameter_name\": \"Consumer number\",\"value\":
\"155555105\"}],\"customer\": {\"customer_name\": \"OG
Test\",\"customer_mobile\": \"1231231234\",\"customer_email\":
\"agtest1@Testcomny.com\",\"customer_pan\": \"AEPM123RC4\",\"customer_aadhaar\":
\"123123123123\"},\"metadata\": {\"agent\": {\"agentid\":
\"BD001MPY100000100001\",\"sub_agentid\": \"BD001MPY11\"},\"device\":
{\"mobile\": \"9800000000\",\"geocode\": \"19.075984,72.877656\",\"postal_code\":
\"400053\",\"ip\": \"124.124.1.1\",\"channel\": \"INT\",\"branchCode\":
\"UTI00030\",\"terminalid\": \"123123\",\"imei\": \"123123123\",\"mac\": \"11-AC-
58-21-1B-AA\",\"os\": \"iOS\",\"app\": \"AGENTAPP\",\"user_agent\":
\"Mozilla\",\"dvc_fngrprnt\": \"AB22331DF49A\"}}}";
【问题讨论】:
-
原始来源是什么样的?
-
它们的含义相同吗? JSON 没有唯一甚至规范的表示,多个不同的字符串可以编码相同的值;例如,JSON 中的许多不同位置可能有额外的空格、制表符或换行符(任何类型)。
-
见php.net/manual/en/function.json-encode.php第二个参数java和php的JSON编码默认选项是不同的
-
嗨,你能添加你重新编码的 json 的转储吗?
-
是的@MatthieuBesson