AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

TJSONValue und Dezimalzahlen

Ein Thema von Codehunter · begonnen am 13. Jul 2018 · letzter Beitrag vom 17. Jul 2018
 
Der schöne Günther

Registriert seit: 6. Mär 2013
6.199 Beiträge
 
Delphi 10 Seattle Enterprise
 
#7

AW: TJSONValue und Dezimalzahlen

  Alt 16. Jul 2018, 09:24
So ungefähr?

Delphi-Quellcode:
type
   TJsonObjectHelper = class helper for System.JSON.TJSONObject
      function FindPair(const PairName: String): TJSONPair;
   end;

procedure p();
const
   input = '{"key": 123.400}';
var
   jsonObject: TJSONObject;
   jsonPair: TJSONPair;
begin
   jsonObject := TJsonObject.ParseJSONValue(input) as TJSONObject;
   try
      jsonPair := jsonObject.FindPair('key');
      WriteLn( jsonPair.JsonValue.ToString() ); // Ergibt "123.400"
   finally
      jsonObject.Destroy();
   end;
end;

{ TJsonObjectHelper }

function TJsonObjectHelper.FindPair(const PairName: String): TJSONPair;
var
  Candidate: TJSONPair;
  I: Integer;
begin
  for I := 0 to Count - 1 do
  begin
   Candidate := TJSONPair(self.FMembers[I]);
   if (Candidate.JsonString.Value = PairName) then
   begin
     Exit(Candidate);
   end;
  end;
  Result := nil;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:58 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz