Jump to content

Search the Community

Showing results for tags 'json'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

There are no results to display.

Forums

  • Welcome to Smart Mobile Studio
    • News and Information
    • Pre-Sales Questions
    • Smart In the Media
    • Smart Contests
    • Meta
  • Smart Mobile Studio Discussion
    • General
    • IDE
    • RTL
    • Code
    • Client Server
    • Platform
    • Graphics
    • Deployment
    • Suggestion box
  • Smart Mobile Studio support
    • Support
    • Bug report
  • General Discussion
    • Pascal
    • Delphi
    • Javascript
    • HTML/HTML5
    • CSS
  • Resources
    • Website
    • Download Smart Mobile Studio

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Company name


Position

Found 9 results

  1. OK, I have looked at examples and I am sure I am just overlooking something simple. I have a REST service returning simple results for various tables in a database. The results can vary in the number of fields returned and the field names can be different. I know that I should be able to write a generic function to parse this JSON pattern, but I just can't seem to figure it out in SMS. I know I can do it with Javascript, but I am hoping someone can help fill in a blank I am missing in processing JSON with SMS. Below are two sample JSON text strings that I'd like to parse and add to a grid dynamically. SAMPLE JSON ONE: [{"id":"1","name":"Joe"},{"id":"2","name":"Jill"},{"id":"3","name":"Sam"}] SAMPLE JSON TWO: [{"id_person":"1","first":"Joe","last":"Smith"},{"id_person":"2","first":"Jill","last":"Jones"},{"id":"3","first":"Sam","last":"Butler"}] I am solid on creating columns as needed, adding data to cells, etc. What I can't figure out is how to generically read each JSON string and determine what the fields are for each and then extracting the data for each item. Can anyone provide some help. Sometimes it is the easy things that get me. I have done this in Delphi without any issues in the past, but I need a little direction for SMS to shorten the learning curve. Thanks.
  2. Ricardo

    JSON Post

    Hi All. This is my first post. I need help to start my first test project. I want to send and receive json objects to a server socket on port 8082. The json structure to send is like this: {"Command":"Open","Table":"Client","Code":"XXXX"} The json structure to reveive is like this: {"Code":"XXXX", "Name":"Name of client",.....} My version of SMS is 3.0.0.201 Thanks!!
  3. COMFIED

    Reading a JSON POST

    I'm trying to build a Facebook messenger bot. It requires reading and sending JSON data from messenger. Sending a json post message is no problem. Anyone with an idea on how to READ incoming JSON POST data using SMARTMOBILESTUDIO? In other words can a SMARTMOBILESTUDIO html webapp work as a webhook?
  4. I use the following snippets below to read a JSON file of data: As you can see, in my UpdateContent method, I have access to the fPresidents data structure - after reading in the JSON file in the InitializeForm event (e.g. FHttp.Get('res\presidents.json'); ) QUESTION: Is it possible to make modifications to the JSON file and then write it back out? (e.g. FHttp.Put('res\presidents.json') ); ? If not, what are my alternatives? uses ... SmartCL.Inet, ECMA.JSON; TfrmNavigation = class(TW3Form) procedure frmNavigationActivate(Sender: TObject); private {$I 'Navigation:intf'} FHttp: TW3HttpRequest; fPresidents: Variant; fJSONStr: String; protected procedure HandleHttpDataReady(Sender:TW3HttpRequest); procedure InitializeForm; override; procedure InitializeObject; override; public procedure UpdateContent; end; procedure TfrmNavigation.InitializeObject; begin inherited; {$I 'Navigation:impl'} ... FHttp := TW3HttpRequest.Create; FHttp.OnDataReady:= HandleHttpDataReady; end; procedure TfrmNavigation.InitializeForm; begin inherited; ... FHttp.Get('res\presidents.json'); end; procedure TfrmNavigation.HandleHttpDataReady(Sender:TW3HttpRequest); begin fJSONStr:= Sender.ResponseText; asm @fPresidents = JSON.parse(@fJSONStr); end; UpdateContent; ... end; procedure TfrmNavigation.UpdateContent; begin fScroll.Content.InnerHTML:= '<div>' + '<h2><center>' + fPresidents.presidents[fIndex].rank + '</center></h2><br>' + '<h2><center>' + fPresidents.presidents[fIndex].name + '</center></h2><br>' + '<h3><center>' + fPresidents.presidents[fIndex].dates + '</center></h3><br>' + '<center> <img src="' + 'res\' + intToStr(fIndex + 1) + '.jpg' + '" alt="image" height="150" width="150" style="border:5px solid red"> </center><br>' + '<p>' + fPresidents.presidents[fIndex].notes + '</p>' + '</div>'; end;
  5. IElite

    TW3HttpRequest

    Is it possible to perform user authentication between client app and server using SMS? I want my app to authenticate with a server, and either return a JSON with a error message, or a JSON with user profile data. Is this possible? If so, what do I need on the server side to perform the request? e.g. this gets an HTML document from google FHttp.Get('http://www.google.com'); I want to instead, post a username and password and in return get JSON (error message not authenticated, or some user profile data) but it doesn't look like TW3HttpRequest object has a put method however, there is a Open method. Can something like this be done? fHTTP.Open('POST','http://mywebsite.com/login.php'); if so, how do I pass the parameters UserId and Password?
  6. bilcan

    Reading JSON data

    What is the way of reading that kind of JSON data. I tried some ways which I found at the forum but I could not. {This is Embarcadero example of Json} uses System.json; var Obj, ObjCons, ObjIpp: TJSONObject; begin Obj := TJSONObject.Create; try ObjIpp := TJSONObject.Create; ObjIpp.AddPair('ipp', TJSONNumber.Create(1122368)); ObjCons := TJSONObject.Create; ObjCons.AddPair('decision', 'NA'); ObjCons.AddPair('idPatient', ObjIpp); ObjCons.AddPair('idStructure', TJSONNumber.Create(300000000023887)); Obj.AddPair('consentement', ObjCons); Memo1.Lines.Add(Obj.ToJSON); finally Obj.Free; end; end;
  7. Learning Javascript is essential to understanding SMS and how it all works. Pack books is giving away a free Javascript e-book daily and today I picked up " JavaScript and JSON Essentials [eBook]", Yesterday I got "Object-Oriented JavaScript - Second Edition [eBook]" and the first one I got was " AngularJS Directives [eBook]" It's a hard deal to beat. https://www.packtpub.com/
  8. The documentation demo posted on http://smartmobilestudio.com/documentation/networking/tw3httprequest/works - but not with all JSON files. It works with the file http://date.jsontest.com/but when I try a different JSON file the data is not displayed in the memo. For example, I'm trying to download the file http://api.worldbank.org/countries/all/indicators/SP.POP.TOTL?format=json from the World Bank open data but the file is not loaded into the memo field. Could it be the JSON format?
  9. In addition to Delphi and FreePascal clients, our framework is now able to access any mORMot server from HTML5 / AJAX rich client, thanks to Smart Mobile Studio. Take a look at this series of blog articles: Units and platforms; Generating the client code wrappers; Delphi / FreePascal clients; Smart Mobile Studio clients. There is no package to be installed within the Smart Mobile Studio IDE. The client units will be generated directly from the mORMot server. Any edition of Smart is enough: you do not need to pay for the Enterprise edition to consume mORMot services. But of course, the Professionnal edition is recommended, since the Basic edition does not allow to create forms from the IDE, which is the main point for an AJAX application. In contrast to the wrappers available in the Enterprise edition of Smart, for accessing RemObjects or DataSnap servers, our mORMot clients are 100% written in the SmartPascal dialect. There is no need to link an external .js library to your executable, and you will benefit of the obfuscation and smart linking features of the Smart compiler. A set of object pascal units will provide a solid and shared ground for the any kind of clients: Connection to a mORMot server via HTTP, with full REST support; Support of weak or default authentication to secure the transfer - see Authentication; Definition of the TSQLRecord class, using RTTI when available on Delphi orFreePascal, and generated code for Smart Mobile Studio; Remote CRUD operations, via JSON and REST, with a TSQLRestClientURI class, with the same methods as with the mORMot.pas framework unit; Optimized TSQLTableJSON class to handle a JSON result table, as returned bymORMot's REST server ORM - see JSON (not) expanded layouts; Batch process - see BATCH sequences for adding/updating/deleting records - for transactional and high-speed writes; Client-Server services via methods with parameters marshaling; Client-Server services via interfaces with parameters marshaling and instance-life time; Mapping of most supported field types, including e.g. ISO 8601 date/time encoding, BLOBs and TModTime/TCreateTime; Complex record types are also exported and consumed via JSON, on all platforms (for both ORM and SOA methods); Some cross-platform low-level functions and types definitions, to help share as much code as possible between your projects. Hope you find it interesting! Smart Mobile Studio rocks!
×
×
  • Create New...