1
比方說,我有以下的JSON:傑克遜 - 如何應用基於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成員中。
傑克遜怎麼能實現這一點?