gpt4 book ai didi

json - ObjectToJsonString首字母大写

转载 作者:行者123 更新时间:2023-12-03 18:44:41 28 4
gpt4 key购买 nike

我使用的Web服务在字段名称的大写/小写方面非常严格(IMO不合理)。

我正在使用TJSON.ObjectToJsonString,并且它使用小写形式显示所有字段名称。 ObjectToJsonString的所有选项都围绕着日期格式,所以我有点茫然。

德尔菲对象

TGeocodeServiceAddress = class(TInterfacedObject, IGeocodeServiceAddress)
private
FAbbreviationFormat: String;
FCountryPostalFilter: String;
FCountry: String;
FCounty: String;
FState: string;
FCity: string;
FStreetAddress: String;
FZip : String;
public
{getters and setters here. Edited for brevity}

property Zip: String read GetZip write SetZip;
property AbbreviationFormat: String read GetAbbreviationFormat write SetAbbreviationFormat;
property CountryPostalFilter: String read GetCountryPostalFilter write SetCountryPostalFilter;
property Country: String read GetCountry write SetCountry;
property County: String read GetCounty write SetCounty;
property State: string read GetState write SetState;
property City: string read GetCity write SetCity;
property StreetAddress: String read GetStreetAddress write SetStreetAddress;
end;


JSON字串

{  
"abbreviationFormat":"",
"countryPostalFilter":"",
"country":"USA",
"county":"PIMA",
"state":"AZ",
"city":"TUCSON",
"streetAddress":"6400 E. 6th St",
"zip":"85711"
}

最佳答案

https://community.idera.com/developer-tools/programming-languages/f/delphi-language/69467/json---converting-array-of-custom-records-to-json-text

uses
...
REST.Json.Types,
...

type
CEItem= class
public
[JsonName('RowName')]
RowName: String;
[JsonName('Name')]
Name: String;
[JsonName('MaxStackSize')]
MaxStackSize: FixedUInt;
...
end;

关于json - ObjectToJsonString首字母大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47930165/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com