我认为没有任何其他 JSON 解析器插件,但恕我直言,您的问题是您需要特定的格式,而不仅仅是任何类型的有效 JSON。
如果您无法更改 JSON 解析器,我想您可以在 NSIS 中对 JSON 进行后处理(此代码不处理所有类型的引号或转义引号!):
Function PrettyOnelineJSON
Exch $0
Push $1
Push $2
Push $3
Push $4
StrCpy $1 "" ; In quote?
StrCpy $2 "" ; Prev. char.
StrCpy $3 "" ; Pos.
loop:
StrCpy $4 $0 1 $3
StrCmp $4 "" done
IntOp $3 $3 + 1
StrCmp $4 " " 0 +2
StrCmp $4 $2 eatone ; Was this and the previous character a space?
StrCpy $2 $4
StrCmp $4 "$\n" eatone
StrCmp $4 "$\r" eatone
StrCmp $4 '"' 0 loop
StrCmp $4 $1 +3
StrCpy $1 $4
Goto loop
StrCpy $1 ""
Goto loop
done:
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
Return
eatone:
StrCmp $1 "" 0 loop ; In a quoted string?
StrCpy $4 $0 "" $3
IntOp $3 $3 - 1
StrCpy $0 $0 $3
StrCpy $0 $0$4
Goto loop
FunctionEnd
Section
StrCpy $0 '"obj": [$\n "a A a A",$\n "b",$\n "c"$\n ]'
MessageBox mb_ok ORG=|$0|
Push $0
Call PrettyOnelineJSON
Pop $0
MessageBox mb_ok NEW=|$0|
SectionEnd