Skip to content

反序列化报错 #79

@CCc3120

Description

@CCc3120

对象转成json传输后反序列化报错

image
@test
public void testJson() throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(SerializationFeature.INDENT_OUTPUT, true)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.setTimeZone(TimeZone.getTimeZone("GMT+8"))
.setLocale(Locale.CHINA);

    Completion completion = Completion.builder().prompt("你好啊").build();


    String jsonStr = objectMapper.writeValueAsString(completion);

    Completion completion1 = objectMapper.readValue(jsonStr, Completion.class);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions