Gson解析未引用的值 [英] Gson parse unquoted value

查看:113
本文介绍了Gson解析未引用的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目GSON库中使用,一切都很好,但现在我遇到了一个问题,我需要使用自定义的反序列化器来处理未引用的值。

I using in my project GSON library, everything is fine, but now i'm stuck with a problem, where i need to use a custom deserializer on unquoted values.

我有以下值,需要从json中解析:
$ b

I have the following value, and need to parse from json:


[[county,=,field_name], [name,ilike,username]]

[ ["county","=", field_name], ["name", "ilike", "username"] ]

我需要使用自定义解串器解析未加引号的值,包装类,如:

I need to parse unquoted values with a custom deserializer, to a wrapper class like:

public class StringField {
    private String value;

    public String getValue() {
        return value;
    }

}

值将会有field_name作为字符串。

And value will have "field_name" as string.

推荐答案

几年前,我用另一种方式解决了这个问题(抱歉延迟)。写了符号预处理器类,它用 field_name 等正则表达式标签替换模型中的实际值,然后解析出json。

I've solved this problem years ago in another way (sorry for delayed). Wrote symbolic preprocessor class, which replace by regexp labels like field_name with actual values from model and then parsed json.

这篇关于Gson解析未引用的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆