Reception pass json array, receiving and processing the background

Here the front desk pass over the json data format like this
[{
		"type": 0,
		"stem": "123",
		"deletionFlag": 1,
		"choice": ["A"],
		"postId": "123",
		"solution":["A", "B"],
		"score": 12.12,
		"materialIds": "123"
	},
	{
		"type": 1,
		"stem": "234",
		"deletionFlag": 1,
		"choice": ["A", "B", "C"],
		"postId": "234",
		"solution": ["A", "B"],
		"score": 12.23,
		"materialIds": "234"
	},
	{
		"type": 2,
		"stem": "345",
		"deletionFlag": 1,
		"choice": ["A", "B"],
		"postId": "345",
		"solution":["A", "B"],
		"score": 12.34,
		"materialIds": "345"
	}
]
  • Here, if the background by directly receiving List is not enough, since the choice of solution and still a data array, direct access being given
  • Thinking: Because json format is the key / value, you can use ListTo install, after removing key corresponding to the value by type
  // Save
    @RequestMapping(value = "/submit", method = RequestMethod.POST)
    public APIResponseBean saveHomeWork(@RequestBody List<Map<String, Object>> homeworklist) {

        if (homeworklist == null) {
                         throw new GlobalException (Constants.HTTP_UNPROCESSABLE_ENTITY, "Submissions parameter error.");
        }

        List<HomeworkBean> saveList = new ArrayList<>();

        for (Map<String, Object> homeworkBeanMap : homeworklist) {
                         // test
//            System.out.println(homeworkBean);

                         // Get the id id be judged according to whether to add or modify
            String id = (String) homeworkBeanMap.get("id");
            
                         / * Submit answer * /
            ArrayList solutionList = (ArrayList) homeworkBeanMap.get("solution");
            String solution = String.valueOf(solutionList);
                         ............................. omitted

Intelligent Recommendation

Java background receiving parameters are enumerated, how does postman's json pass in

Using the Postman test interface, one of the parameters is enumeration type, how to pass the parameter? 1 Meeting type: 2 Java physical class: 3. Controller control class 4 Postman uses JSON to pass t...

JSON transfer array object to the background process and reception (TP framework)

In the TP framework, the front desk sends an array-type json string to the backend, and the json string obtained by the I method in the background will change (you can capture the package under chrome...

_014_js_JavaScript ajax pass in the background using the request receiving array example

From https://blog.csdn.net/yhj19920417/article/details/48690439, thanks to the author's selfless sharing. 1, the front desk in the array variable jsp: 2, the property is provided in ajax: Ajax code ex...

jQuery ajax pass json array to the background

jQuery ajax pass json array to the background The front end code is as follows: Background code: Here is the params, which is data:{params:JSON.stringify(arr)}. The key of the aqx passed in the parame...

JSON and PHP pass value and reception

First, JS array turn JSON format transmission Keywords: json.stringify () Second, PHP receives JSON pass value Keywords: (1)html_entity_decode() (2) JSON_DECODE ($ list, true): The second parameter mu...

More Recommendation

Background receiving Json request parameter compatible array and single object

Suger team Author: Yu you peace background Scene 1: The front-end and docking interfaces are added, deleted, and checked. The parameters requested at the beginning are basically a single piece of data...

Backstage pass reception json data via Ajax (json array, there is also a single field)

Background json array package, single-field json: Front-end acquisition:...

Background data transfer json + ajax request processing using the reception data json

Background using json response transmission data (data in the database from the list, change to the front desk to json data transmission. No use @ResponseBody, in fact, this may be) Front Desk: First,...

information reception processing javascript json

information reception processing javascript json ajax obtaining interface information, javascript json information processing itself; By eval () json the received character string into a real object i...

Receiving a set of parameters of the array or reception parameters

Receiving a set of parameters of the array or reception parameters type of array need not be specified, but the collection @RequestParam required to specify the type for example as follows: String arr...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top