Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-01

FPJSONRTTI: Case insensitive.

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

I have this JSON:

{ "id": 1, "name": "Silvio Clécio" }

And my object is:

TPerson = class
private
  FID: Int64;
  FName: string;
published
  property ID: Int64 read FID write FID;
  property Name: string read FName write FName;
end;

But, FPJSONRTTI don't find the fields, except if I change my class to:

  property id: Int64 read FID write FID;
  property name: string read FName write FName;

Or my JSON to:

{ "ID": 1, "Name": "Silvio Clécio" }

So, how to I find all fields but in case insensitive? (like TypInfo functions)

Thank you!

ps. Marshal of Delphi is case insensitive.

ps2. So, I send this my questions only to fpc-devel or fpc-pascal? :/

Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Michael Van Canneyt
to silvioprog
silvioprog wrote 5 lines
Hello, I have this JSON: { "id": 1, "name": "Silvio Clécio" }

JSON is JavaScript and JavaScript *is* case sensitive.

But you can use TJSONObject.IndexOfName with CaseInsentive to True:

     Function IndexOfName(const AName: TJSONStringType; CaseInsensitive : Boolean = False): Integer;

Line 450 of fpjsonrtti could be changed to set this to True, but it will have a bad impact on performance. Maybe we can have a property for this.

You should fix your incoming JSON instead.

Michael.

Reply by email