I serialize the form to Dart in JSON and then submit it to the Spring MVC backend, using Jackson to deserialize JSON.
In the dart, if I print JSON, I get:
{firstName: piet, lastName: venter}
Jackson does not like the data in this format, he returns the status of 400 and The request sent by the client was syntactically incorrect.
If I put quotation marks in all fields, Jackson accepts the data and I get a response.
{"firstName": "piet", "lastName": "venter"}
In dart, I build a Map<String, String> data = {};, then go through all the fields of the form anddata.putIfAbsent(input.name, () => input.value);
Now, when I call data.toString(), I get unspecified JSON, which I assume is invalid JSON.
If I import 'dart:convert' show JSON;try JSON.encode(data).toString();, I get the same unordered JSON.
Double quotes are added manually:
data.putIfAbsent("\"" + input.name + "\"", () => "\"" + input.value + "\"");
On the Java side, there is no rocket:
@Controller
@RequestMapping("/seller")
@JsonIgnoreProperties(ignoreUnknown = true)
public class SellerController {
@ResponseBody
@RequestMapping(value = "/create", method = RequestMethod.POST, headers = {"Content-Type=application/json"})
public Seller createSeller(@RequestBody Seller sellerRequest){
, , Dart JSON ( ), ?
Jackson JSON?