Skip to content

Instantly share code, notes, and snippets.

@reinaldoacdc
Created March 14, 2022 18:05
Show Gist options
  • Save reinaldoacdc/3868e681d523c038d5dfe2cdbc023ba9 to your computer and use it in GitHub Desktop.
Save reinaldoacdc/3868e681d523c038d5dfe2cdbc023ba9 to your computer and use it in GitHub Desktop.
unit JsonObjectHelper;
interface
uses DBXJSON, Character;
type TJsonObjectHelper = class helper for TJsonObject
public
//Helper to find a JSON pair based on the pair string part
function Get(const PairName: UnicodeString): TJSONPair; overload;
end;
implementation
function TJsonObjectHelper.Get(const PairName: UnicodeString): TJSONPair;
var
Candidate: TJSONPair;
I: Integer;
begin
for i := 0 to Size - 1 do
begin
Candidate := Get(i);
if (Candidate.JsonString.Value = PairName) then
Exit(Candidate);
end;
Result := nil;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment