S
S
student_12022-02-21 12:01:46
Java
student_1, 2022-02-21 12:01:46

How to write json which contain array of objects in pojo?

Hello, the question is actually above.
when I try to pass json and write to pojo I get null
621354ebe91c6766882124.png
I have two classes and one controller:

@Data
@Component
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class Activity1 {

    private String NAME;
    private String code;
    private String NOTE;
}


@Data
@Getter
@Setter
@Component
public class TestDto {

    private Activity1 ACTIVITY;
}


@RestController
@RequiredArgsConstructor
public class BaseController {

    @PostMapping("/save")
    public ResponseEntity<List<TestDto>> save(@RequestBody List<TestDto> testDtos){
        return ResponseEntity.ok().body(testDtos);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2022-02-21
@student_1

Tell me, does the different case of letters in the request and in the response (although there are the same DTOs) give you any thoughts?
And here I am prompted that Jackson serializes and deserializes fields with names from small letters. Either configure Jackson to understand large letters - or send the request with small letters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question