#1 2015-12-24 14:55:27

AArhin
Member
Registered: 2013-12-30
Posts: 10

Use Json Library standalone

Hi Dear All,
      I want to use the Json library as a standalone unit in my project.
I am using D2007 and would want some help in creating , reading and parsing individual data elements json data.
Particularly how to create Json Array types in code without a seed data aka { "items": [...]}.
Trying to migrate my data transfer format from xml to json.

Thanks

Offline

#2 2015-12-24 15:07:26

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Use Json Library standalone

You would find everthing you need in SynCommons.pas.

Take a look at the TDocVariant custom variant type.
See http://synopse.info/files/html/Synopse% … ml#TITL_80

Online

#3 2015-12-25 06:43:31

AArhin
Member
Registered: 2013-12-30
Posts: 10

Re: Use Json Library standalone

Thanks Boss,
I may be not qualified to say what a powerful framework you have built.
I just tried my hands at below code and I have an idea how I am going to solve the issue I have in my project.

   TDocVariant.New(JsonObject);
   JsonObject.SessionDate := '01012016';
   JsonObject.TotalItemsCount := 29;
   JsonObject.TotalItemsValue := 290.87;
   JsonObject.Transactions := _Arr([]);
   for i := 0 to 100 - 1 do
   begin
     TDocVariant.New(anElement);
      anElement.ItemName := 'item ' + IntToStr(i);
      anElement.ItemPrice := 10*i;
     JsonObject.Transactions.Add(anElement);
   end;
   Memo1.Lines.Text := JsonObject;

The only issue I have in using this framework is the documentation is not simplified to get one up and going.
The appeal I am making is that, can we have a getting started sort of document.
This is key because it will ease the early pains of adopting the framework.
I have tried so many times to use the framework but to no avail.
But I have been able to adopt Java frameworks such as SparkJava and Dropwizard
in a matter of 2 hours mainly because the documentation is very simplified.

Thanks.
I sincerely hope I can you this framework in my next project where I shall convert an Old Asta based  server to Mormot

Offline

#4 2015-12-25 13:54:42

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Use Json Library standalone

Hi AArhin,

This might be of helpful: https://tamingthemormot.wordpress.com/

Aside from that, I'm afraid at this moment you'll have to bear with this fact smile


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#5 2015-12-25 19:30:52

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 357

Re: Use Json Library standalone

You can't compare mORMot with this two lightweight frameworks/libraries. Sure, you need only JSON, but the docu is about all.
To understand mORMot you need a year. It is not easy, but if you really need it, there is no other way.

Offline

#6 2015-12-26 09:54:44

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Use Json Library standalone

Take a look at the samples at first.

They are usually helpful and easy to understand.

Online

#7 2015-12-26 11:27:13

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Use Json Library standalone

Agreed! start from the supplied samples (over 30 samples!) and it's very very easy to understand.

Last edited by edwinsn (2015-12-26 13:23:09)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB