mars-men / GsonFormatPlus

GsonFormatPlus
Apache License 2.0
143 stars 34 forks source link

希望支持把 json 大驼峰命名的 key 转为小驼峰的变量名 #11

Closed Edger closed 3 years ago

Edger commented 3 years ago

RT。

json 返回的数据的字段都是大驼峰命名的,希望转换之后可以改为小驼峰命名。

mars-men commented 3 years ago

转换哪一种JSON,是Idea么?

Edger commented 3 years ago

转换哪一种JSON,是Idea么?

Android Studio,Gson 的

junziqiao commented 3 years ago

已经修复了

Edger commented 3 years ago

已经修复了

还是不行,在 Android Studio 和 IDEA 里都升级了,转换之后还是大驼峰命名。

附上我用的 json 和设置 :

    {
        Version: 1,
        Key: "335315",
        Type: "City",
        Rank: 55,
        LocalizedName: "State College",
        EnglishName: "State College",
        PrimaryPostalCode: "16801",
        Region: {
            ID: "NAM",
            LocalizedName: "North America",
            EnglishName: "North America"
        },
        Country: {
            ID: "US",
            LocalizedName: "United States",
            EnglishName: "United States"
        },
        AdministrativeArea: {
            ID: "PA",
            LocalizedName: "Pennsylvania",
            EnglishName: "Pennsylvania",
            Level: 1,
            LocalizedType: "State",
            EnglishType: "State",
            CountryID: "US"
        },
        TimeZone: {
            Code: "EDT",
            Name: "America/New_York",
            GmtOffset: -4,
            IsDaylightSaving: true,
            NextOffsetChange: "2017-11-05T06:00:00Z"
        },
        GeoPosition: {
            Latitude: 40.793,
            Longitude: -77.86,
            Elevation: {
                Metric: {
                    Value: 377,
                    Unit: "m",
                    UnitType: 5
                },
                Imperial: {
                    Value: 1236,
                    Unit: "ft",
                    UnitType: 0
                }
            }
        },
        IsAlias: false,
        SupplementalAdminAreas: [
            {
                Level: 2,
                LocalizedName: "Centre",
                EnglishName: "Centre"
            }
        ],
        DataSets: [
            "Alerts",
            "ForecastConfidence",
            "MinuteCast"
        ]
    }
junziqiao commented 3 years ago

你这个json,首字母变成小写,就可以吗? ----- 原始邮件 ----- 发件人:Edger Lea notifications@github.com 收件人:mars-men/GsonFormatPlus GsonFormatPlus@noreply.github.com 抄送人:junziqiao junziqiao@sina.com, State change state_change@noreply.github.com 主题:Re:_[mars-men/GsonFormatPlus]_希望支持把_json_大驼峰命名的_key转为小驼峰的变量名(#11) 日期:2021年02月05日 09点56分

已经修复了

还是不行,在 Android Studio 和 IDEA 里都升级了,转换之后还是大驼峰命名。

附上我用的 json 和设置 :

{

    Version: 1,

    Key: "335315",

    Type: "City",

    Rank: 55,

    LocalizedName: "State College",

    EnglishName: "State College",

    PrimaryPostalCode: "16801",

    Region: {

        ID: "NAM",

        LocalizedName: "North America",

        EnglishName: "North America"

    },

    Country: {

        ID: "US",

        LocalizedName: "United States",

        EnglishName: "United States"

    },

    AdministrativeArea: {

        ID: "PA",

        LocalizedName: "Pennsylvania",

        EnglishName: "Pennsylvania",

        Level: 1,

        LocalizedType: "State",

        EnglishType: "State",

        CountryID: "US"

    },

    TimeZone: {

        Code: "EDT",

        Name: "America/New_York",

        GmtOffset: -4,

        IsDaylightSaving: true,

        NextOffsetChange: "2017-11-05T06:00:00Z"

    },

    GeoPosition: {

        Latitude: 40.793,

        Longitude: -77.86,

        Elevation: {

            Metric: {

                Value: 377,

                Unit: "m",

                UnitType: 5

            },

            Imperial: {

                Value: 1236,

                Unit: "ft",

                UnitType: 0

            }

        }

    },

    IsAlias: false,

    SupplementalAdminAreas: [

        {

            Level: 2,

            LocalizedName: "Centre",

            EnglishName: "Centre"

        }

    ],

    DataSets: [

        "Alerts",

        "ForecastConfidence",

        "MinuteCast"

    ]

}

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

junziqiao commented 3 years ago

image 这个json 属性怎么属性怎么用字符串包着

mars-men commented 3 years ago

junziqiao 在1.5.9版本已支持,正在提交审核

Edger commented 3 years ago

junziqiao 在1.5.9版本已支持,正在提交审核

👍 非常感谢!

不知道后面能不能加上自动生成 toString 方法?