Fastjson Automatic conversion parameter error

Source: Internet
Author: User

Development environment: spring-mvc4.1.7, fastjson1.2.7

Problem Description: The system adopts the full separation of the front and back end, the front-end page uses Ajax to invoke the background service, want to use Fastjson automatic conversion request Parameter object.

Front-end invocation
"Bas/test.do""POST"true"Application/json; Charset=utf-8 "function(RST) {alert (json.stringify (RST));}
  @ResponseBody  2  @RequestMapping (value = "/add.do", method = {requestmethod.post, requestmethod.get}, produces = "application/ Json;charset=utf-8 ")  3  public  void   add (@RequestBody country Country) { 4  //  ... 5 } 
Run the error stack as follows:
for Servlets [SPRINGMVC] in the context with path [/MFD] threw exception [Request processing failed; nested exception Is Com.alibaba.fastjson.JSONException:syntax error, expect {, actual error, POS 00 at Com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze (Javabeandeserializer.java:232)

Search for various solutions on the Web The result of the last attempt to convert the JSON object into a JSON string was successfully called.

Modified to Data:JSON.stringify (country)

When using Jackson on the previous project, the data parameter passed directly to the JSON object, which is not supported by Fastjson ...

Fastjson Automatic conversion parameter error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.