假设我有以下json:
{
"first_path": "/just/a/path",
"second_path": "/just/another/path",
"relative_path": { "$relative": "some_file" },
}
我有我无法修改的课程:
public class Paths {
public String first_path;
public String second_path;
public String third_path; // Can't mark this with annotations
}
我想要的是对所有字符串值应用一些自定义反序列化逻辑,如果它们在 json 中看起来像 { "$...": "..." }。在我的示例中,我显然要根据一些逻辑将相对路径转换为绝对路径,并将绝对路径放入 Paths.third_path 成员。
我如何与杰克逊一起实现这一目标?