Home json json parser for Delphi

json parser for Delphi

Author

Date

Category

What to Poule JSON? Are there any normal and lungs in mastering JSON parsers?


Answer 1, Authority 100%

All after all on the official website of JSONA listed:


Answer 2, Authority 15%

uses
 Data.dbxjson.
// ..
var.
 Jsonobject: tjsonobject;
Begin.
 Jsonobject: = tjsonobject.parsejsonvalue ('{"Name", "Value"}') AS TJSONOBJECT;
 ShowMessage ('Name'). Jsonvalue.Value)

But does not want to parse data type {123: “Value”}
Posted by such a “patch”:

class function tjsonobject.parsepair (Const Br: TJSONBYTEREADER; Const Parent: TJSONOBJECT): integer;
var.
 Pair: TJSONPAIR;
 Commapos: Integer;
Begin.
 Pair: = tjsonpair.create;
 Parent.AddDescendant (Pair);
// Commapos: = ParsEstring (Br, pair); /////////////////////////////// //
{Zubina Schob Bachilo Row Type {33:33}
 Consumewhitespaces (br);
 IF Br.peekbyte in [ORD ('0') .. ORD ('9')] THEN
  Commapos: = PARSENUMBER (Br, pair)
 ELSE.
  Commapos: = Parsestring (Br, pair);
{/}
 IF Commapos & GT; 0 Then.
 Begin.
  Consumewhitespaces (br);
  IF Br.Empty then.
   Exit (-br.offset);
  IF Br.peekbyte & lt; & gt; ORD (':') THEN
   Exit (-br.offset);
  Br.consumebyte;
  Consumewhitespaces (br);
  Commapos: = Parsevalue (Br, pair);
 end;
 Result: = Commapos;
end;

just replaced the appropriate bull (you can save in another file)


Answer 3, Authority 8%

Starting with Delphi 2010 there is a built-in JSON support (DATA.DBXJSON module) in the DBExpress technology, also in addition to the libraries already listed, another one from Andreas HausLaden , author IDE Tools for Delphi: JSON Data Objects , Supported versions starting from 2009.


Answer 4, Authority 8%

Result would be ashamed to be ashamed, but I did not get a single one from the options, so I wrote my own: https: / /Github.com/Badunius/Myjson

UPD: NOT arranged first of all the bulky, requiring to work with nestedness or to start the horde of variables, or to build too unreadable chains. Bringing types, though progressive, but also readability does not add. I used to work with JSON in JS, so I was important to the maximum syntax similarity.

ah yes, and the main requirement, of course, was compatible with Delphi 7, because I still use it.


Answer 5

In the latest versions of Delphi, there is a built-in library JSON

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions