• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Registering
V2EX  ›  程序员

Gson 解析时遇到编程语言关键字怎么解决

  •  
  •   Registering · Jul 22, 2015 · 3402 views
    This topic created in 3971 days ago, the information mentioned may be changed or developed.
    刚调用第三方api,发现返回的json其中一个字段叫private。

    使用java ,gson解析该json

    不可能在定义对象时定义其中的成员变量为
    private String private;


    怎么破呢
    3 replies    2015-07-23 09:17:06 +08:00
    Registering
        1
    Registering  
    OP
       Jul 22, 2015   ❤️ 1
    解决了

    这样

    @SerializedName("private")
    private boolean isPrivate;
    jsuper
        2
    jsuper  
       Jul 22, 2015
    @SerializedName, 请多看下官方文档赛
    StevenTong
        3
    StevenTong  
       Jul 23, 2015
    能自己解决最好 平时多看文档
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2734 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 05:30 · PVG 13:30 · LAX 22:30 · JFK 01:30
    ♥ Do have faith in what you're doing.