Jackson is Not parsing Chinese chars.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Jackson is Not parsing Chinese chars.

ankit8051
Hi all.

I am using Jackson's ObjectMapper for parsing input json. It is not parsing the input Chinese chars.

I am using below Json.

{
 data:{
            "first_name":"東京都台東区千束2-26-9",
            "last_name":"コムロコーポ202"
          }
}

I am using below code for parsing.

ctx.getRequest().getBody().map(TypedData::getText).then(t -> {
                if (StringUtils.isNotEmpty(t)) {
                    ObjectMapper mapper = new ObjectMapper();
                    CreditCardJsonEntity<CreditCard> creditCardJsonEntity = mapper.readValue(t,
                                                new TypeReference<CreditCardJsonEntity<CreditCard>>() {
                });
             }
     }

While i tried to print this thing on console it will display as ?????? chars,  even when i tried to save the data into database it is showing the same thing.

Am I missing something?

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Jackson is Not parsing Chinese chars.

danveloper
Administrator
What's your runtime environment? (i.e. What operating system, what system properties, global Java options, etc?)
Reply | Threaded
Open this post in threaded view
|

Re: Jackson is Not parsing Chinese chars.

ankit8051
Hi danveloper,

Below are my system properties,


java.runtime.name: Java(TM) SE Runtime Environment
sun.boot.library.path: C:\Program Files\Java\jdk1.8.0_65\jre\bin
java.vm.version: 25.65-b01
java.vm.vendor: Oracle Corporation
java.vendor.url: http://java.oracle.com/
path.separator: ;
java.vm.name: Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg: sun.io
user.country: US
user.script:
sun.java.launcher: SUN_STANDARD
sun.os.patch.level: Service Pack 1
PID: 12704
java.vm.specification.name: Java Virtual Machine Specification
user.dir: D:\Ankit_Data\Workspace\treeni\roller
java.runtime.version: 1.8.0_65-b17
java.awt.graphicsenv: sun.awt.Win32GraphicsEnvironment
org.jboss.logging.provider: slf4j
java.endorsed.dirs: C:\Program Files\Java\jdk1.8.0_65\jre\lib\endorsed
os.arch: amd64
java.io.tmpdir: C:\Users\A71B4~1.PAT\Temp\
line.separator:

java.vm.specification.vendor: Oracle Corporation
user.variant:
os.name: Windows 7
sun.jnu.encoding: Cp1252
spring.beaninfo.ignore: true
java.library.path: C:\Program Files\Java\jdk1.8.0_65\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_65/bin/server;C:/Program Files/Java/jre1.8.0_65/bin;C:/Program Files/Java/jre1.8.0_65/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Ruby21-x64\bin;E:\app\a.patel\product\11.2.0\client_1\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;.;C:\apache-tomcat-6.0.32\bin;C:\apache-ant-1.8.2\bin;C:\apache-maven\bin;C:\Program Files\Java\jdk1.8.0_65\bin;C:\grails-2.2.1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\VisualSVN\bin;C:\Program Files\TortoiseSVN\bin;C:\spring-roo\bin;C:\mongodb\bin;C:\PROGRA~2\XRay;C:\Python27;c:\cygwin\bin;c:\cygwin\usr\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Windows Live\Shared;C:\gradle-2.9\bin;C:\spring-boot\bin;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\Program Files (x86)\OpenSSH\bin;E:\Hadoop\hadoop-2.3.0\bin;C:\Program Files (x86)\scala\bin;C:\PSTools;C:\Python34;C:\PROGRA~2\Groovy\GROOVY~1.6\bin;C:\Program Files (x86)\Skype\Phone\;C:\Sun\AppServer\bin;G:\Software\eclipse-jee-mars-1-win32-x86_64\eclipse;;.
sun.nio.ch.bugLevel:
java.specification.name: Java Platform API Specification
java.class.version: 52.0
sun.management.compiler: HotSpot 64-Bit Tiered Compilers
os.version: 6.1
user.home: C:\Users\a.patel
catalina.useNaming: false
user.timezone: Asia/Calcutta
java.awt.printerjob: sun.awt.windows.WPrinterJob
@appId: csapi
file.encoding: Cp1252
java.specification.version: 1.8
catalina.home: C:\Users\a.patel\Temp\tomcat.8892521839277354523.8080
java.class.path:D:\Ankit_Data\Workspace\treeni\roller\bin;C:\gradle-2.9\caches\modules-2\files-2.1\aopalliance\aopalliance\1.0\235ba8b489512805ac13a8f9ea77a1ca5ebe3e8\aopalliance-1.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\cglib\cglib-nodep\3.2.0\cf1ca207c15b04ace918270b6cb3f5601160cdfd\cglib-nodep-3.2.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.1.3\d90276fff414f06cb375f2057f6778cd63c6082f\logback-classic-1.1.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.1.3\e3c02049f2dbbc764681b40094ecf0dcbc99b157\logback-core-1.1.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.6.4\ecbd5ad4efa46c8e88522751a80841a49e81a34d\jackson-annotations-2.6.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.6.4\27d3a9f7bbdcf72d93c9b2da7017e39551bfa9fb\jackson-core-2.6.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.6.4\f2abadd10891512268b16a1a1a6f81890f3e2976\jackson-databind-2.6.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.fasterxml.jackson.dataformat\jackson-dataformat-yaml\2.6.4\6c0892da11d9e7d75c3fa2e49ec2bf7c14a1ae8c\jackson-dataformat-yaml-2.6.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-guava\2.6.2\3535dd92e8849c6b97f425d5c3d07fcb4e0140e7\jackson-datatype-guava-2.6.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk7\2.6.4\34fed916a3dc42f1bc9f7a71eb048638c6c0bda\jackson-datatype-jdk7-2.6.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.6.4\7e613a59c5de6d10c3b4665e8c1c0c175baf8777\jackson-datatype-jdk8-2.6.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.6.4\d4e062ad01d022be33a8366043500eed3905db3c\jackson-datatype-jsr310-2.6.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.fasterxml\classmate\1.1.0\dbbd699a1486ad0f2ed6f5af6cfed66acacb9056\classmate-1.1.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.github.ben-manes.caffeine\caffeine\2.2.6\472291cda8957f45a2e203f15b048cdfd4f261cf\caffeine-2.2.6.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.google.guava\guava\18.0\cce0823396aa693798f8882e64213b1772032b09\guava-18.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.google.inject.extensions\guice-multibindings\4.0\f4509545b4470bbcc865aa500ad6fef2e97d28bf\guice-multibindings-4.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.google.inject\guice\4.0\f990a43d3725781b6db7cd0acf0a8b62dfd1649\guice-4.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.h2database\h2\1.4.190\df71536d44e3b07f0c15bb632cac51956c55fc3e\h2-1.4.190.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.netflix.archaius\archaius-core\0.7.1\657d41df404ad5b51272ea3da86f744988f96ac\archaius-core-0.7.1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.netflix.hystrix\hystrix-core\1.4.21\c7bc2e31932ced2e4947a02dfffa0d2af592b59d\hystrix-core-1.4.21.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.netflix.hystrix\hystrix-javanica\1.4.21\f210312d2cd54d2a0947fa5840ed5e7ffc24f96f\hystrix-javanica-1.4.21.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.netflix.hystrix\hystrix-metrics-event-stream\1.4.21\a6082322e3d5b71b8a1b7057198acff3e38c8e8b\hystrix-metrics-event-stream-1.4.21.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.oracle\ojdbc6\11.2.0.2.0\2f89cd9176772c3a6c261ce6a8e3d0d4425f5679\ojdbc6-11.2.0.2.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.sun.mail\javax.mail\1.5.4\2dd6b709ca0d35853a6061c83434a9b94533b877\javax.mail-1.5.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\com.zaxxer\HikariCP\2.4.3\9f92ff5b04c7fcfb1c2fbcf551406d0a79cd3619\HikariCP-2.4.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\commons-beanutils\commons-beanutils\1.9.2\7a87d845ad3a155297e8f67d9008f4c1e5656b71\commons-beanutils-1.9.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\commons-codec\commons-codec\1.9\9ce04e34240f674bc72680f8b843b1457383161a\commons-codec-1.9.jar;C:\gradle-2.9\caches\modules-2\files-2.1\commons-collections\commons-collections\3.2.2\8ad72fe39fa8c91eaaf12aadb21e0c3661fe26d5\commons-collections-3.2.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\commons-configuration\commons-configuration\1.8\6cce40435bcd8018018f16898de01976b319941a\commons-configuration-1.8.jar;C:\gradle-2.9\caches\modules-2\files-2.1\commons-digester\commons-digester\2.1\73a8001e7a54a255eef0f03521ec1805dc738ca0\commons-digester-2.1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\commons-lang\commons-lang\2.6\ce1edb914c94ebc388f086c6827e8bdeec71ac2\commons-lang-2.6.jar;C:\gradle-2.9\caches\modules-2\files-2.1\commons-logging\commons-logging\1.2\4bfc12adfe4842bf07b657f0369c4cb522955686\commons-logging-1.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\commons-validator\commons-validator\1.5.0\26b98c21975c5caf6bf34bacdeb7183be7a65970\commons-validator-1.5.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.netty\netty-buffer\4.1.0.CR7\a660b187504cb96d9cf80bbb9b377b66bdb083b3\netty-buffer-4.1.0.CR7.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.netty\netty-codec-http\4.1.0.CR7\7673ce860316cb6e1701021e9f342a0a0b80627a\netty-codec-http-4.1.0.CR7.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.netty\netty-codec\4.1.0.CR7\6f1c3f2c5d4a9f6f1b66a51fe99b581387a9fd30\netty-codec-4.1.0.CR7.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.netty\netty-common\4.1.0.CR7\98956a9b0de61bd1df48badc700074282d8a81a1\netty-common-4.1.0.CR7.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.netty\netty-handler\4.1.0.CR7\82510921660148357ee3a3745c0b36491830d6eb\netty-handler-4.1.0.CR7.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.netty\netty-resolver\4.1.0.CR7\dd1b7eeb825326dc22eb9c8afaadab32467d781\netty-resolver-4.1.0.CR7.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.netty\netty-transport-native-epoll\4.1.0.CR7\18e64d5f1493f867bb82ecf332c17b4365ef20bb\netty-transport-native-epoll-4.1.0.CR7-linux-x86_64.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.netty\netty-transport\4.1.0.CR7\8e37fbd8817ac6b494e52e1f7a1b21bcf507b719\netty-transport-4.1.0.CR7.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.ratpack\ratpack-core\1.3.3\82504a254adb4eaead7f127f6145003669c23528\ratpack-core-1.3.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.ratpack\ratpack-groovy-test\1.3.3\cd585d98c07b18f6b6bc74c0a548c5b530f64941\ratpack-groovy-test-1.3.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.ratpack\ratpack-groovy\1.3.3\34230f9bf9c4e1b0e8c0fd253b9b4f62ef154096\ratpack-groovy-1.3.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.ratpack\ratpack-guice\1.3.3\e9e3401ab9ed49fdb76000966c0e0b2ac8b65be0\ratpack-guice-1.3.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.ratpack\ratpack-hystrix\1.3.3\7b139da7939999c08c6cb3d1893eab32ec429df7\ratpack-hystrix-1.3.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.ratpack\ratpack-rx\1.3.3\bf8df61adc34223af0fdb4076a9aee6bc6546145\ratpack-rx-1.3.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.ratpack\ratpack-spring-boot\1.3.3\e00cd4aa59793d131e56df4d8abd4f52aa07415e\ratpack-spring-boot-1.3.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.ratpack\ratpack-test\1.3.3\b8e7ebca010774136bb753217b82c5ff56fe0dae\ratpack-test-1.3.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.reactivex\rxjava-reactive-streams\1.0.1\87d6f207aee10615e108f7121a873f787ab92408\rxjava-reactive-streams-1.0.1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\io.reactivex\rxjava\1.0.14\898f9ab61e2a23afd615f0b0389478bec86f49f9\rxjava-1.0.14.jar;C:\gradle-2.9\caches\modules-2\files-2.1\it.sauronsoftware.cron4j\cron4j\2.2.5\da0dd0edee48b570cd1e23895e0ac80e09eb272b\cron4j-2.2.5.jar;C:\gradle-2.9\caches\modules-2\files-2.1\javax.activation\activation\1.1\e6cb541461c2834bdea3eb920f1884d1eb508b50\activation-1.1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\javax.inject\javax.inject\1\6975da39a7040257bd51d21a231b76c915872d38\javax.inject-1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\javax.validation\validation-api\1.1.0.Final\8613ae82954779d518631e05daa73a6a954817d5\validation-api-1.1.0.Final.jar;C:\gradle-2.9\caches\modules-2\files-2.1\junit\junit\4.12\2973d150c0dc1fefe998f834810d68f278ea58ec\junit-4.12.jar;C:\gradle-2.9\caches\modules-2\files-2.1\net.logstash.logback\logstash-logback-encoder\4.4\8af0af78b5814611c28d30f3d9450ef18c786b20\logstash-logback-encoder-4.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\net.sf.jpam\jpam\1.1\cb3d91c2dfda767518a371dbb02edfd6a4aa0600\jpam-1.1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.commons\commons-lang3\3.1\905075e6c80f206bbe6cf1e809d2caa69f420c76\commons-lang3-3.1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient\4.5.1\7e3cecc566df91338c6c67883b89ddd05a17db43\httpclient-4.5.1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.4.4\b31526a230871fbe285fbcbe2813f9c0839ae9b0\httpcore-4.4.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.mina\mina-core\2.0.7\c878e2aa82de748474a624ec3933e4604e446dec\mina-core-2.0.7.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.sshd\sshd-core\0.11.0\450da44553c98805ca6bb5709cad54df4acb802a\sshd-core-0.11.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.sshd\sshd-pam\0.11.0\b939ceb742cefc1c632132111b8e4facc41b3d38\sshd-pam-0.11.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\8.0.30\87b12667b258d0135f7cf4234030a5ccbb55193f\tomcat-embed-core-8.0.30.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\8.0.30\b97d5ff750126d7fdaf412aeec219306bd157e50\tomcat-embed-el-8.0.30.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-logging-juli\8.0.30\c19b5c37e1f67bf58f9726b438d5323411cd43c6\tomcat-embed-logging-juli-8.0.30.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\8.0.30\84cf6feff7ed4f73689b4fa076cc6ec33851e075\tomcat-embed-websocket-8.0.30.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.tomcat\tomcat-jdbc\8.0.30\44765cbbe3ea864923c16f19e081522f8058a6a5\tomcat-jdbc-8.0.30.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.apache.tomcat\tomcat-juli\8.0.30\48258c438c681d1322ccb15f01d58238d14c1274\tomcat-juli-8.0.30.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.8.7\f753e78bbe484e58b3b4e5ce3cc1751e50d11f6c\aspectjweaver-1.8.7.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.bouncycastle\bcpkix-jdk15on\1.51\6c8c1f61bf27a09f9b1a8abc201523669bba9597\bcpkix-jdk15on-1.51.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.51\9ab8afcc2842d5ef06eb775a0a2b12783b99aa80\bcprov-jdk15on-1.51.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-all\2.4.5\1730f61e9c9e59fd1b814371265334d7be0b8d2\groovy-all-2.4.5.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.codehaus.groovy\groovy\2.4.4\62dc4f50804c40f3233977e2d3d1a4abca60bc41\groovy-2.4.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.codehaus.jackson\jackson-core-asl\1.9.13\3c304d70f42f832e0a86d45bd437f692129299a4\jackson-core-asl-1.9.13.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.codehaus.jackson\jackson-mapper-asl\1.9.13\1ee2f2bed0e5dd29d1cb155a166e6f8d50bbddb7\jackson-mapper-asl-1.9.13.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.crashub\crash.cli\1.3.2\98101f8591be8612ddd5fec2ae884c3f1026eddc\crash.cli-1.3.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.crashub\crash.connectors.ssh\1.3.2\3705258c976ddc428ad0d72be99bc4f7891c408\crash.connectors.ssh-1.3.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.crashub\crash.embed.spring\1.3.2\6ca5b3cffe798ad4b9b42356b4af179e9f21891e\crash.embed.spring-1.3.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.crashub\crash.plugins.cron\1.3.2\40a5063e6c930ede0ce1d59baf592b7bdcafb1ff\crash.plugins.cron-1.3.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.crashub\crash.plugins.mail\1.3.2\b88f401ff420b678d35328b685e23b7008741633\crash.plugins.mail-1.3.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.crashub\crash.shell\1.3.2\3bbaaa18968b9c25f850c7f0469cd8fc3fcd0b7e\crash.shell-1.3.2.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.freemarker\freemarker\2.3.23\cd143cd8c02a9f838e3cb75a6dfe133750437f6d\freemarker-2.3.23.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core\1.3\42a25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.hamcrest\hamcrest-library\1.3\4785a3c21320980282f9f33d0d1264a69040538f\hamcrest-library-1.3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.hibernate\hibernate-validator\5.2.2.Final\990905cd9184450c5f3e929ab2566305e3a67fa1\hibernate-validator-5.2.2.Final.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.javassist\javassist\3.18.1-GA\d9a09f7732226af26bf99f19e2cffe0ae219db5b\javassist-3.18.1-GA.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.3.0.Final\3616bb87707910296e2c195dc016287080bba5af\jboss-logging-3.3.0.Final.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.json\json\20140107\d1ffca6e2482b002702c6a576166fd685e3370e3\json-20140107.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.mockito\mockito-core\1.10.19\e8546f5bef4e061d8dd73895b4e8f40e3fe6effe\mockito-core-1.10.19.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.objenesis\objenesis\2.1\87c0ea803b69252868d09308b4618f766f135a96\objenesis-2.1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.ow2.asm\asm\5.0.4\da08b8cce7bbf903602a25a3a163ae252435795\asm-5.0.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.projectlombok\lombok\1.16.6\9d3a47307466b28632bf35f8972ae9d703879416\lombok-1.16.6.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.reactivestreams\reactive-streams\1.0.0\14b8c877d98005ba3941c9257cfe09f6ed0e0d74\reactive-streams-1.0.0.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.slf4j\jcl-over-slf4j\1.7.13\d78d2242e14e4182625152d225f76ae52b43491d\jcl-over-slf4j-1.7.13.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.13\43759e986de5fec7045e35e9533e5ad2f6cd1b05\jul-to-slf4j-1.7.13.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.slf4j\log4j-over-slf4j\1.7.13\b5f4685073a6ffba6bf7e1d51e2b5fb83bdfa953\log4j-over-slf4j-1.7.13.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.13\7fcf30c25b8f4a9379b9dad0d3f487b25272c026\slf4j-api-1.7.13.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.spockframework\spock-core\1.0-groovy-2.4\ceaa8b69f274ed3de24da3e6a6c86f673b426d1a\spock-core-1.0-groovy-2.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.spockframework\spock-spring\1.0-groovy-2.4\a07c753a95114872cd753ce3ae9166b64284b31d\spock-spring-1.0-groovy-2.4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-actuator-docs\1.3.1.RELEASE\2e50e74c729f564eea5bde21521bbe6ab0bd1dfa\spring-boot-actuator-docs-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-actuator\1.3.1.RELEASE\7a1a3945517ee71360e4008bb9724bc4cb8f9fe4\spring-boot-actuator-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\1.3.1.RELEASE\16ecb1f0b3ccbc8ecd52fa9de57a273d5a3eea00\spring-boot-autoconfigure-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-configuration-processor\1.3.1.RELEASE\7d6e0b8dc02139bce74de7385bf934f18d5fe1a1\spring-boot-configuration-processor-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-devtools\1.3.1.RELEASE\aa620233ef8b7dfabb298add128848c100aef24f\spring-boot-devtools-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-actuator\1.3.1.RELEASE\7671f6c69cf25a513b555ddb4ffab64a9b1fc194\spring-boot-starter-actuator-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\1.3.1.RELEASE\898d3fe97caf7dd88b42357e1643318753b0cf4e\spring-boot-starter-aop-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-cache\1.3.1.RELEASE\62660d7f0be81ccb5a069ed40ec862e39ebf84ba\spring-boot-starter-cache-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-freemarker\1.3.1.RELEASE\2e51073222e9c33e9ffad93c8deb800bc0b770c\spring-boot-starter-freemarker-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\1.3.1.RELEASE\6fdd3124a3aa9eaa4d4ac0adde03c734676e40bd\spring-boot-starter-jdbc-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\1.3.1.RELEASE\ba9d2d5094d83cf40dab474d6526befb5ce85a74\spring-boot-starter-logging-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-mail\1.3.1.RELEASE\552000cfd2240da089f88b4fafab8b602c3a65ea\spring-boot-starter-mail-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-remote-shell\1.3.1.RELEASE\59b844141a9db04a33a21ccfe93e424f4e2af6b8\spring-boot-starter-remote-shell-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-security\1.3.1.RELEASE\8a71c21b3d9ef6bdd80623b66cfa56fa82270f6\spring-boot-starter-security-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-test\1.3.1.RELEASE\53c089ab224613e9ae1d3f9ec58efb2a2229b152\spring-boot-starter-test-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\1.3.1.RELEASE\3c21bd7269af0df9b2d1b67581eec191e70faeb5\spring-boot-starter-tomcat-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-validation\1.3.1.RELEASE\47f424e3c7ed629b988b1976e52b662834a76856\spring-boot-starter-validation-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\1.3.1.RELEASE\dd3c0e6cdee57e591eabc95a33b16233547eec91\spring-boot-starter-web-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\1.3.1.RELEASE\622e02ce77b3bea202b596a6fa0c40525ec81e1c\spring-boot-starter-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\1.3.1.RELEASE\7ea554d1d14e180ee080abc3e7c19e316a700188\spring-boot-1.3.1.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-commons\1.1.0.M4\d33991715471ab473eae653744e6f347d94aeaab\spring-cloud-commons-1.1.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-config-client\1.1.0.M4\548be005b0d00a785b1f4b8ef7318e5c58088b36\spring-cloud-config-client-1.1.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-context\1.1.0.M4\f6e5bad29aa8191818f20b7b8b79676a0410d0bf\spring-cloud-context-1.1.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-netflix-core\1.1.0.M4\62eca2292d36f0a1fde6a724b4eb2edcb7333362\spring-cloud-netflix-core-1.1.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-netflix-hystrix-dashboard\1.1.0.M4\e773ef512dc2374f8ac5c94ac4d614592e5aad36\spring-cloud-netflix-hystrix-dashboard-1.1.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-security\1.1.0.M3\8ba7295d01bc360c0aacc6b0bd1db026781431c0\spring-cloud-security-1.1.0.M3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-sleuth-core\1.0.0.M4\1a180e6bad9e97b788ffe8206af4d61805ac6f99\spring-cloud-sleuth-core-1.0.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-starter-config\1.1.0.M4\49eb0a770d92e67a2fb5557fd5d5ad4c19a9882a\spring-cloud-starter-config-1.1.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-starter-hystrix-dashboard\1.1.0.M4\6f749c0b1afa2f5155d67f248361b0f64c3f8a67\spring-cloud-starter-hystrix-dashboard-1.1.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-starter-hystrix\1.1.0.M4\43833889c70f601ea0a6759811f6919f5c18bd53\spring-cloud-starter-hystrix-1.1.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-starter-oauth2\1.1.0.M3\6ba6163728129086d44e2e13e5ba28c93b89778d\spring-cloud-starter-oauth2-1.1.0.M3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-starter-security\1.1.0.M3\bc532cc2da04f5fa3de1ba41d81123da9b549551\spring-cloud-starter-security-1.1.0.M3.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-starter-sleuth\1.0.0.M4\10af103df0737c74ac01332881cc737af4e8f4f2\spring-cloud-starter-sleuth-1.0.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.cloud\spring-cloud-starter\1.1.0.M4\fa837dec03e87c9a2eb6840451086e5535ba40af\spring-cloud-starter-1.1.0.M4.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.hateoas\spring-hateoas\0.19.0.RELEASE\77b3b15c301d2517356b76304a2670df33ef2e2c\spring-hateoas-0.19.0.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.security.oauth\spring-security-oauth2\2.0.8.RELEASE\d02b4025f64318436af7a3b3dea339cd12915a20\spring-security-oauth2-2.0.8.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.security\spring-security-config\4.0.3.RELEASE\31c0a4d0159f1b668d9512f57fb46aac29949b08\spring-security-config-4.0.3.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.security\spring-security-core\4.0.3.RELEASE\9f420c5742ad063970c5d33f60680a1cee777aa5\spring-security-core-4.0.3.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.security\spring-security-crypto\4.0.3.RELEASE\46802f89ed4b7894b527058aeaeeab7fba53276a\spring-security-crypto-4.0.3.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.security\spring-security-jwt\1.0.3.RELEASE\6adde06e8a1f977ca13e2f684ab92715420d402a\spring-security-jwt-1.0.3.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework.security\spring-security-web\4.0.3.RELEASE\5f0233d94ca53ac8710780b43791f633f970480a\spring-security-web-4.0.3.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-aop\4.2.4.RELEASE\3329cf71b4bc49c9767ca4f0704ed7b773f29fba\spring-aop-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-beans\4.2.4.RELEASE\dc8e0874b53435f3e277d9da5aebd8b93cc7cf64\spring-beans-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-context-support\4.2.4.RELEASE\428f5d6ab3eba5ddd0b89474379ccfe867a42cc1\spring-context-support-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-context\4.2.4.RELEASE\23cd0109e4eafc5629547e3680b0c4031e82efdd\spring-context-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-core\4.2.4.RELEASE\160ccd89230753d4f49477a967f5876b034d9745\spring-core-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-expression\4.2.4.RELEASE\15b6f6d61bc68fe2cc6cbd63e2329601afb8b39\spring-expression-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-jdbc\4.2.4.RELEASE\7aa1c3c817b0a04796e6570a2c07ac23248c1ee0\spring-jdbc-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-test\4.2.4.RELEASE\6efb87acf8050fc83334ffac305eb91371787283\spring-test-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-tx\4.2.4.RELEASE\66e1a131263f5f9ba95943061b22ff2666930ca6\spring-tx-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-web\4.2.4.RELEASE\d4bcc6f4d8b64d7af9b67bc17f0d5106dce97926\spring-web-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.springframework\spring-webmvc\4.2.4.RELEASE\cf4317be9c83b4c1c65ce2d3bb96673ac546030a\spring-webmvc-4.2.4.RELEASE.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.webjars\d3js\3.4.11\6ef8866c242eddc2bb7f6ef5b93028b73d316e23\d3js-3.4.11.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.webjars\jquery\2.1.1\dd89e356066869550b5509c4370f995ad6698d9a\jquery-2.1.1.jar;C:\gradle-2.9\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.16\d64fb662c9e42789149f5078a62a22edda786c6a\snakeyaml-1.16.jar
user.name: a.patel
java.vm.specification.version: 1.8
sun.java.command: com.roller.cloud.api.resource.cs.RollApiApplication
java.home: C:\Program Files\Java\jdk1.8.0_65\jre
sun.arch.data.model: 64
user.language: en
java.specification.vendor: Oracle Corporation
awt.toolkit: sun.awt.windows.WToolkit
java.vm.info: mixed mode
java.version: 1.8.0_65
java.ext.dirs: C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path: C:\Program Files\Java\jdk1.8.0_65\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_65\jre\classes
java.awt.headless: true
java.vendor: Oracle Corporation
catalina.base: C:\Users\a.patel\Temp\tomcat.807877961705332591.8080
file.separator: \
LOG_EXCEPTION_CONVERSION_WORD: %wEx
java.vendor.url.bug: http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding: UnicodeLittle
sun.cpu.endian: little
sun.desktop: windows
sun.cpu.isalist: amd64
Reply | Threaded
Open this post in threaded view
|

Re: Jackson is Not parsing Chinese chars.

danveloper
Administrator
The problem is likely with your character encoding. This is worth a read: http://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding
Reply | Threaded
Open this post in threaded view
|

Re: Jackson is Not parsing Chinese chars.

Luke Daley
Administrator
In reply to this post by ankit8051
I suggest not taking the request body to text before decoding the JSON. This will be more efficient, and avoids encoding issues.

ctx.getRequest().getBody().map(TypedData::getInputStream).then(t -> {
    if (t.available() > 0) {
        ObjectMapper mapper = new ObjectMapper();
        CreditCardJsonEntity<CreditCard> creditCardJsonEntity = mapper.readValue(t,
            new TypeReference<CreditCardJsonEntity<CreditCard>>() {}
        );
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Jackson is Not parsing Chinese chars.

ankit8051
Thanks Luke,

Still getting the same thing.

I have also tried with TypedData:getBytes as well, but no effect on the output.


Reply | Threaded
Open this post in threaded view
|

Re: Jackson is Not parsing Chinese chars.

Luke Daley
Administrator
That alludes to the encoding mismatch happening somewhere else.

This could happen if your database is running with a charset that doesn't support these characters, or if you render to the console from a JVM who's charset doesn't support these characters.

Can you please try cutting it down to a self contained example that we could try running.
Reply | Threaded
Open this post in threaded view
|

Re: Ratpack is Not parsing Chinese chars.

ankit8051
Hi Luke,

Below is my whole application code::
Note:: Database code is skipped.

---------------------------------------------------------------------------------------------------------------------------------------
1) build.gradle

buildscript {
        ext {
                springBootVersion = '1.3.3.RELEASE'
        }
        repositories {
                jcenter()
                mavenCentral()
        }
        dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
                classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.1.9'
                classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
        }
}


apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'jacoco'
apply plugin: 'info.solidsoft.pitest'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'

group = "com.cygnet.cloud.api"

version = "1.0.0-SNAPSHOT"

jacoco {
        toolVersion = "0.7.1.201405082137"
        reportsDir = file("$buildDir/customJacocoReportDir")
}

compileJava {
        options.compilerArgs = ["-Xlint:unchecked", "-Xlint:deprecation"]
        options.fork = true
}

war {
        manifest {
                attributes("Implementation-Title": "Gradle", "Implementation-Version": version)
        }
        baseName = 'demo'
        version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8



repositories {
        jcenter()
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
}


dependencies {
        compile("org.springframework.boot:spring-boot-starter-tomcat")
        compile('org.springframework.boot:spring-boot-starter-actuator')
        compile('org.springframework.boot:spring-boot-actuator-docs')
        compile('org.springframework.boot:spring-boot-starter-cache')
        compile('org.springframework.boot:spring-boot-starter-jdbc')
        compile('org.springframework.boot:spring-boot-starter-logging')
        compile('org.springframework.boot:spring-boot-devtools')
        compile('org.projectlombok:lombok:1.16.6')
        compile('org.springframework.boot:spring-boot-starter-mail')
        compile('io.ratpack:ratpack-spring-boot:1.3.3')
        compile('io.ratpack:ratpack-rx:1.3.3')
        compile('io.ratpack:ratpack-hystrix:1.3.3')
        compile('org.springframework.boot:spring-boot-starter-remote-shell')
        compile('org.springframework.boot:spring-boot-starter-validation')
        testCompile('cglib:cglib-nodep:3.2.0')
        testCompile('org.springframework.boot:spring-boot-starter-test')
        testCompile('org.spockframework:spock-spring:1.0-groovy-2.4')
        testCompile('org.spockframework:spock-core:1.0-groovy-2.4')
    testCompile('io.ratpack:ratpack-test:1.3.3')
    testCompile('io.ratpack:ratpack-groovy-test:1.3.3')
}

dependencyManagement {
        imports {
                mavenBom "org.springframework.cloud:spring-cloud-starter-parent:Brixton.M4"
        }
}

test {
        useTestNG()
        useJUnit()
        jacoco {
                append = false
                destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
                classDumpFile = file("$buildDir/jacoco/classpathdumps")
        }
}

eclipse {
        classpath {
                 containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
                 containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
        }
}

task wrapper(type: Wrapper) {
        gradleVersion = '2.9'
}


jacocoTestReport {
        reports {
                xml.enabled false
                csv.enabled false
                html{
             enabled true
             destination "${buildDir}/jacocoHtml"
            }
        }
}

---------------------------------------------------------------------------------------------------------------------------------------
2) DemoApplication.java

package org.gradle;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import ratpack.spring.config.EnableRatpack;

@SpringBootApplication
@EnableRatpack
public class DemoApplication {
    public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
        }
}

---------------------------------------------------------------------------------------------------------------------------------------
3) Router.java

/**
 *
 */
package org.gradle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import ratpack.func.Action;
import ratpack.handling.Chain;

@Component
public class Router implements Action<Chain> {
       
        @Autowired
        DemoHandler demoHandler;

        public void execute(Chain chain) throws Exception {
                chain.prefix("demo", chain1 -> chain1.all(demoHandler));
        }

}

---------------------------------------------------------------------------------------------------------------------------------------
4) DemoHandler.java

/**
 *
 */
package org.gradle;

import org.springframework.stereotype.Component;
import static ratpack.jackson.Jackson.json;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import ratpack.handling.Context;
import ratpack.handling.Handler;
import ratpack.http.TypedData;

/**
 * @author a.patel
 *
 */
@Component
public class DemoHandler implements Handler {

        public void handle(Context ctx) throws Exception {
                ctx.byMethod(m -> m.get(() -> {
                        ctx.render("INSIDE GET METHOD");
                }).post(() -> {
                        ctx.getRequest().getBody().map(TypedData::getInputStream).then(t -> {
                                if (t.available() > 0) {
                                        ObjectMapper mapper = new ObjectMapper();
                                        CreditCard creditCardJsonEntity = mapper.readValue(t,
                                                        new TypeReference<CreditCard>() {
                                        });
                                        ctx.render(json(creditCardJsonEntity));
                                }
                        });
                                               
                }));
        }

}

---------------------------------------------------------------------------------------------------------------------------------------
5) CreditCard.java

/**
 *
 */
package org.gradle;

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;

@Data
public class CreditCard {

        @JsonProperty("first_name")
        private String firstName;
        @JsonProperty("last_name")
        private String lastName;
       
}

---------------------------------------------------------------------------------------------------------------------------------------
URL ::

POST http://localhost:5050/demo/

Input Data::

{
        "first_name":"東京都台東区",
        "last_name":"Patel"
        }

Output::

{
   "first_name": "??????",
   "last_name": "Patel"
}

If you need more details please let me know.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Ratpack is Not parsing Chinese chars.

ankit8051
Thanks, Luke.

Thanks for your help.

Thanks for your finding that the issue is in the Rest Client(SOAPUI tool) which I am using for testing.

Really appreciate your help.