自動変速機の文字列のJSON文字列エスケープを装う\ソリューション

(値= { "/ sysOrgRest / getInfoByOrgIds"}、メソッド= {org.springframework.web.bind.annotation.RequestMethod.POST})@RequestMapping 
公共ボイドgetInfoByOrgIds(@RequestBody文字列PARAM){
{試みる
前に「(log.infoをPARAMは{}」、PARAM)です。
IF(param.contains( "\" ")){
PARAM = org.apache.commons.lang.StringEscapeUtils.unescapeJava(PARAM);
PARAM = param.replaceFirst(" \ ""、 "");
PARAM = param.substring(0、param.length() - 1)。
}
log.info( "PARAM後{}である"、PARAM)。
JSONObjectオブジェクト= JSONObject.parseObject(PARAM)。
もし(object.containsKey( "enterpriseid")&& object.containsKey(」
一覧<ロング> orgIds =(一覧<ロング>)object.get( "orgIds");
整数enterpriseid =(整数)object.get( "enterpriseid")。
}
}キャッチ(例外e){
log.error(e.getMessage()、E)。
}


<! - https://mvnrepository.com/artifact/commons-lang/commons-lang - > 
<依存>
<groupIdを>コモンズ-LANG </ groupIdを>
<たartifactId>コモンズ-LANG </たartifactId>
<バージョン> 2.6 </バージョン>
</依存関係>



13:39:32.393 expressLog [HTTP-NIO-8889-EXEC-2] DEBUG oswsmmaRequestResponseBodyMethodProcessor -読む"アプリケーション/ JSONを、文字セット= UTF-8" [ "" {\ "orgIds \"に:[477,476,261,1,13] 、\ "enterpriseid \":1} ""]
13:39:32.394 expressLog [HTTP-NIO-8889-EXEC-2] INFOのcom.paic.express.rest.test - paramがある前に"{\" orgIds \」 [477,476,261,1,13]、\ "enterpriseid \":1}」转义了。
13:39:35.576 expressLog [HTTP-NIO-8889-EXEC-2] INFO com.paic.express.rest.test - {[477,476,261,1,13]、 "enterpriseid": "orgIds" 1} PARAM後の解决

おすすめ

転載: www.cnblogs.com/hsq666666/p/11320657.html