简体   繁体   中英

REST Post of JSON object not handling spaces in date value in java

I'm testing a REST post service with the following unix command:

  curl -d "{"begTime":"2012-06-06 01:06:01.744","id":"1"}" http://localhost:8080/Restlet

I print the value with the following RESLET print statement:

 System.out.println("entity ---------" + jString + "--");

when I print the value received in my java app, I see this value:

entity ---------{begTime:2012-06-06--

How can I get the entire date so that it doesn't cut off the rest of the object values?

It looks like a quoting issue to me; the JSON literal has " chars in it. Try this:

curl -d '{"begTime":"2012-06-06 01:06:01.744","id":"1"}' http://localhost:8080/Restlet

If you're getting seriously into this, consider using something other than shell scripting to do this. That's because it can get seriously awkward to get quoting right with shell scripts, relative to what many other scripting languages (Python, Ruby, Perl, Tcl, …, a very long list) do directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM