我可以使用JSON.parse解码任何转义表达式吗?

时间:2017-03-20 13:28:30

标签: javascript json

//test expression 1
\uD798\uB4E0 \uC2DC\uAE30\uC5D0 \uC2DC \uD55C \uD3B8\uC774 \uD070 \uC704\uB85C\uAC00 \uB418\uAE30\uB3C4 \uD569\uB2C8\uB2E4. \uADF8\uB7F0 \uC758\uBBF8\uC5D0\uC11C \uC774 \uCC45\uC740 \uB9CE\uC740 \uC0AC\uB78C\uB4E4\uC5D0\uAC8C \uC704\uB85C\uC640 \uB530\uB73B\uD568\uC774 \uB420 \uCC45\uC774\uB77C\uB294 \uC0DD\uAC01\uC774 \uB4ED\uB2C8\uB2E4. \uCC98\uC74C\uC5D0\uB294 \uB4DC\uB77C\uB9C8\uB97C \uBCF4\uACE0 \uAD6C\uC785\uD558\uAC8C \uB418\uC5C8\uB294\uB370 \uADF8\uB0E5 \uC2DC\uC9D1\uC778 \uC904 \uC54C\uC558\uC2B5\uB2C8\uB2E4. \uBC1B\uC544\uBCF4\uB2C8 \uC67C\uCABD\uC5D0\uB294 \uC2DC\uAC00 \uC368 \uC788\uACE0 \uC624\uB978\uCABD\uC5D0\uB294 \uB3C5\uC790\uAC00 \uC9C1\uC811 \uC2DC\uB97C \uC4F0\uB294 \uD615\uC2DD\uC774\uC5C8\uC2B5\uB2C8\uB2E4. \uC2DC\uB97C \uC77D\uACE0 \uC74C\uBBF8\uD558\uBA74\uC11C \uC2DC\uB97C \uC368 \uB0B4\uB824\uAC00\uB294\uB370 \uADF8 \uB3D9\uC548 \uB290\uAEF4\uBCF4\uC9C0 \uBABB\uD55C \uC704\uB85C\uC640 \uD3C9\uC548\uC744 \uB290\uB07C\uAC8C \uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uC694\uC998\uCC98\uB7FC \uC190\uAE00\uC528\uB97C \uC4F0\uB294 \uAC83\uC774 \uC27D\uC9C0 \uC54A\uC740 \uC2DC\uB300\uC5D0 \uC774\uB807\uAC8C \uC190\uC73C\uB85C \uC9C1\uC811 \uC8FC\uC625\uAC19\uC740 \uC2DC\uB4E4\uC744 \uC190\uC73C\uB85C \uC368 \uBCF4\uB294 \uAC83 \uC790\uCCB4\uAC00 \uD790\uB9C1\uC774 \uB418\uB294 \uAC83 \uAC19\uC2B5\uB2C8\uB2E4

//test expression 2
uAC00\uB054\uC740 \uC2DC \uAC19\uC740 \uAC83\uC744 \uC4F0\uBA74 \uB9C8\uC74C \uC548\uC815\uC774 \uB41C\uB2E4\uB294 \uC18C\uB9AC\uB97C \uB4E3\uB294\uB2E4.  \uC194\uC9C1\uD788 \uC2DC\uB97C \uBCC4\uB85C \uC88B\uC544\uD558\uC9C0 \uC54A\uACE0, \uADF8\uB9AC \uBCF4\uACE0 \uC2F6\uC740 \uC874\uC7AC\uB3C4 \uC544\uB2C8\uB2E4.  \uB3C4\uAE68\uBE44\uB97C \uC5F4\uC815\uC801\uC73C\uB85C \uC2DC\uCCAD\uD558\uB358 \uC5B4\uB290 \uB0A0 \uC2DC\uAC00 \uAC00\uB4DD \uB2F4\uAE34 \uC774 \uCC45\uC744 \uBCF4\uC558\uB2E4.  \uC640\uB2FF\uC558\uB2E4 \uD0DC\uC5B4\uB098\uC11C \uCC98\uC74C\uC73C\uB85C \uC2DC\uC758 \uB2F4\uAE34 \uB0B4\uC6A9\uC774 \uC640\uB2FF\uC740 \uC801\uC740 \uCC98\uC74C\uC774\uB2E4.  \uB3C4\uAE68\uBE44 \uB54C\uBB38\uC774 \uC544\uB2C8\uB2E4 \uC2DC\uC758 \uADF8 \uAD6C\uC808 \uD558\uB098\uD558\uB098\uAC00 \uC644\uBCBD\uD574\uBCF4\uC600\uB2E4.     \uBC14\uB85C \uAD6C\uC785\uD574 \uD558\uB098\uD558\uB098 \uBA3C\uC800 \uC77D\uC5B4\uBCF4\uC558\uB2E4.   \uC815\uB9D0 \uB3C4\uAE68\uBE44\uC5D0\uC11C \uB098\uC628 \uD558\uB098\uC758 \uC2DC\uBFD0\uB9CC \uC544\uB2C8\uB77C \uB098\uBA38\uC9C0 \uC2DC\uB4E4\uB3C4 \uD558\uB098\uAC19\uC774 \uBCF4\uAE30 \uC88B\uC740 \uC2DC\uB4E4, \uADF8\uB0E5 \uC2DC\uAC04\uB0A0 \uB54C \uD55C\uBC88\uCBE4 \uC77D\uC5B4\uBCF4\uBA74 \uC88B\uC740 \uC2DC\uB4E4\uC774 \uAC00\uB4DD\uD588\uB2E4.     \uB610, \uB354 \uC88B\uC740 \uBD80\uBD84\uC740 \uC624\uB978\uCABD \uC885\uC774\uC5D0 \uB0B4\uAC00, \uB098\uC758 \uB290\uB08C\uB300\uB85C \uADF8 \uC2DC\uB97C \uC4F8 \uC218 \uC788\uB2E4\uB294 \uAC83. \uB108\uBB34 \uC88B\uC558\uB2E4. \uD56D\uC0C1 \uD558\uB098\uC529 \uC4F4\uB2E4. \uB9C8\uC74C \uC9C4\uC815\uB418\uACE0 \uADF8 \uC2DC\uC778\uC758 \uB290\uB08C\uC774 \uC544\uB2C8

//test expression 3
\uBC29\uC1A1\uC791\uAC00\uB97C \uAFC8\uAFB8\uB294 \uC870\uCE74\uC5D0\uAC8C \uC120\uBB3C\uD55C \uCC45.   \uB108\uB098\uC5C6\uC774 \uB4DC\uB77C\uB9C8 \'\uB3C4\uAE68\uBE44\'\uC5D0 \uBE60\uC9C4 \uC2DC\uAE30\uC640 \uB9DE\uBB3C\uB824   \'\uC0AC\uB791\uC758 \uBB3C\uB9AC\uD559\' \uB355\uBD84\uC5D0\uB3C4 \uB9DD\uC124\uC774\uC9C0 \uC54A\uACE0 \uCC45\uC744 \uC9D1\uC5B4\uB4E4\uC5C8\uB2E4.  \uC120\uBB3C\uC744 \uD558\uBA70,   \uACE0\uB4F1\uD559\uAD50 \uC785\uD559\uC744 \uC55E\uB454 \uC870\uCE74\uC5D0\uAC8C\uB294   \uC5B4\uB5A4 \uC2DC\uB4E4\uC774 \uBCC4\uCC98\uB7FC \uB9C8\uC74C\uC5D0 \uBC15\uD790\uAE4C \uAD81\uAE08\uD588\uB2E4.     \uC774\uBAA8\uC758 \uB9C8\uC74C\uC744 \uC54C\uC558\uB294\uC9C0   \uC5BC\uB9C8 \uC804 \uC870\uCE74\uB294 \"\uB108\uBB34 \uC88B\uB2E4\"\uBA70   \uD544\uC0AC\uD55C \uD754\uC801\uC744 \uB2F4\uC544 \uCE74\uD1A1\uC73C\uB85C \uC0AC\uC9C4\uC744 \uBCF4\uB0B4\uC654\uB2E4.   \uBC1C\uD0C1\uB41C \uC2DC\uB294 \uAE40\uACBD\uBBF8 \uC2DC\uC778\uC758 \'\uCD08\uC2B9\uB2EC\'.  \"\uC587\uACE0 \uAE34 \uC785\uC220 \uD558\uB098\uB85C/\uC628 \uBC24\uD558\uB298 \uB2E4 \uBB3C\uACE0 \uAC00\uB294/\uAC80\uC740 \uBB3C\uACE0\uAE30 \uD55C \uB9C8\uB9AC//  \uC678\uBFD4 \uD558\uB098\uC5D0/ \uC628 \uBAB8 \uB2E4 \uB04C\uB824\uAC00\uB294 \uAC80\uC740 \uCF54\uBFD4\uC18C \uD55C \uB9C8\uB9AC//  \uAC00\uB2E4\uAC00 \uC7A0\uC2DC \uBA48\uCDB0\uC120 \uAC80\uC815\uACE0\uC591\uC774/\uC785\uC5D0 \uBB3C\uB9B0/\uC0DD\uC120\uCC98\uB7FC \uD30C\uB2E5\uC774\uB294/ \uC740\uC0C9 \uB098\uBB47\uC78E \uD55C \uC7A5//  \uAC80\uC815 \uADF8\uBB3C\uCF54\uB9C8\uB2E4 \uADC0 \uC7A1\uD78C \uBCC4\uBE5B\uB4E4//  \uB098\uB3C4

我申请了JSON.parse('["' + expression + '"]'),但它无效。我想解码这些表达式。它们可以包含任何特殊字符。所以这很难。

1 个答案:

答案 0 :(得分:0)

请考虑以下事项:



const str = "\\uD798\\uB4E0 \\uC2DC\\uAE30\\uC5D0"

console.log(eval('"' + str + '"'));