Recent

Author Topic: Noob and JSON  (Read 11035 times)

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Noob and JSON
« Reply #15 on: July 13, 2018, 03:24:08 pm »
This is still Abracadabra for me.


Isn't their an easier way?
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Noob and JSON
« Reply #16 on: July 14, 2018, 08:59:30 am »
You can never figure it out if you don't try.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Noob and JSON
« Reply #17 on: July 14, 2018, 10:08:26 am »
Why do you ever need a JSON (3-tiered application I guess)?
You said your requirements is simple 5 users application.

In your place (being novice), I would go for a good old simple direct SQL connection.
In case of security concerns (you think one provided by the SQL engine is not enough), use firewalls, ssh tunnels or other admin measures.


Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Noob and JSON
« Reply #18 on: July 14, 2018, 10:54:05 am »
This is still Abracadabra for me.


Isn't their an easier way?
It can't get any easier, after all you're combining multiple concepts together: database access, JSON, client-server through HTTP. Don't expect there will ever be a one liner for all of them, even if it's probably possible.
The hard part of making them available as libraries is already done, using those libraries is the easy part.

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Noob and JSON
« Reply #19 on: July 16, 2018, 09:01:59 am »
Why do you ever need a JSON (3-tiered application I guess)?
You said your requirements is simple 5 users application.

In your place (being novice), I would go for a good old simple direct SQL connection.
In case of security concerns (you think one provided by the SQL engine is not enough), use firewalls, ssh tunnels or other admin measures.
The problem relies on the cloud database.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Noob and JSON
« Reply #20 on: July 16, 2018, 10:20:05 am »
Hi
This scheme is call "NoSQL Database" you can find many reference on web.

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Noob and JSON
« Reply #21 on: July 16, 2018, 11:34:14 am »
The problem relies on the cloud database.

What's problem? Isn't TCP connection available? Even cheapest hosting providers allows that.
« Last Edit: July 16, 2018, 12:59:28 pm by sash »
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Noob and JSON
« Reply #22 on: July 16, 2018, 11:39:29 am »
This is still Abracadabra for me.


Isn't their an easier way?
Sure just make a post on the job section of the forums and pay some one else to do the work for you.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Noob and JSON
« Reply #23 on: July 16, 2018, 04:33:13 pm »
Code: Pascal  [Select][+][-]
  1. function GetURLAsString(const aURL: string): string;
  2. var
  3.   lHTTP: TIdHTTP;
  4. begin
  5.   lHTTP := TIdHTTP.Create;
  6.   try
  7.     Result := lHTTP.Get(aURL);
  8.   finally
  9.     lHTTP.Free;
  10.   end;
  11. end;
  12.  
your result from de webserver could be JSON /XML /CSV or whatever you put in your html/php page.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Noob and JSON
« Reply #24 on: July 17, 2018, 01:09:38 am »
The problem relies on the cloud database.

What's problem? Isn't TCP connection available? Even cheapest hosting providers allows that.
Can you elaborate?
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Noob and JSON
« Reply #25 on: July 17, 2018, 10:05:07 am »
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: Noob and JSON
« Reply #26 on: July 17, 2018, 12:18:50 pm »
This is still Abracadabra for me.


Isn't their an easier way?

Like Leledumbo said earlier, it is just a simple 3 tier application: database access, a server with JSON serialization over HTTP/TCP and a desktop client to talk to the server. It is relatively easy to do this with Indy (using IdHTTP or IdTCP transport), mORMot (REST & HTTP) or even FPC's built in default HTTP/TCP units.

If you want something simpler (drag and drop), I suggest you look at REST Dataware drag and drop components. Even if the author is Brazilian and his YouTube videos are in Portuguese, the images speak for themselves. That is the simplest method I know of.

REST Dataware links
REST Dataware Componentes: http://forum.lazarus-ide.org/index.php/topic,38281.msg259512.html#msg259512
My New Project Lazarus REST/JSON Server/Client: http://forum.lazarus-ide.org/index.php/topic,36290.msg250356.html#msg250356
Youtube videos: https://www.youtube.com/watch?v=6FVXT36j-7U
Sourceforge: https://sourceforge.net/projects/rest-dataware-componentes/?source=directory

Alternatively, you can download and install REST Dataware using the Lazarus Online Package Manager. See screenshot.

Cheers,

JD
« Last Edit: July 17, 2018, 12:22:41 pm by JD »
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Noob and JSON
« Reply #27 on: July 17, 2018, 12:33:35 pm »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Noob and JSON
« Reply #28 on: July 17, 2018, 01:44:47 pm »
That TCP-connection

Well, I don't know your exact configuration, nor your server provider's specifications. "Cloud" database is a marketing, not a strict technical term.

Personally, for a similar tasks I used plain-simple VPS, or even managed LAMP hosting services. In first case I just (installed and) configured (by myself) database server to accept specific external connections. In second case, such feature (if supported by provider) is available in their "Control Panel" or with explicit request to their support. Thus I was able to connect directly (see my above notes about vpn, ssh) from my favorite desktop database tool (or whichever application) to database server on remote host.
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

 

TinyPortal © 2005-2018