NetTalk Central

Author Topic: Records Paging and JSON  (Read 2342 times)

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Records Paging and JSON
« on: February 10, 2015, 05:40:33 AM »
Hello Guys:
  I am writing a WebService using NT8. The program is made for a developer who is writing an app for mobile and consume the data using NetTalk.

  After showing the first approach he was very pleased but he ask me why i did use XML instead of JSON. and the second question (a tricky one i think) if it is possible to page the records i serve to make the app more fast.

  So the two questions are:
  There is a way to serve JSON in the webservice instead of XML in NetTalk?
  There is a way to page large records and deliver by request?

By paging is something like the NetWebBrowse of 10 records, then the next 10 and so on

Any help or suggestions would be appreciated.
« Last Edit: February 10, 2015, 06:19:59 AM by urayoan »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11204
    • View Profile
Re: Records Paging and JSON
« Reply #1 on: February 10, 2015, 07:25:47 AM »
Hi Ura,

>> why i did use XML instead of JSON.

Both are important I think. Mobile tends to be more JSON - especially if the client is built with JavaScript. "Desktop" programs (and servers) tend to use XML more with more structured rules and so on.

>>  There is a way to serve JSON in the webservice instead of XML in NetTalk?

That's coming. I'm working on integrating some JSON classes so the client can choose either JSON or XML, whichever they prefer.

>> There is a way to page large records and deliver by request?

that depends a bit on what you mean. I think you'll need to explain a lot more what you have in mind here. I'm not sure exactly if you mean to reduce the number of records in each reply, or you want to send the reply in pieces, or what you have in mind...

cheers
Bruce

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: Records Paging and JSON
« Reply #2 on: February 10, 2015, 07:31:57 AM »
Hi Bruce!
  Nice to hear that JSON classes are coming to NT in near future.


>>that depends a bit on what you mean. I think you'll need to explain a lot more what you have in mind here. I'm not sure exactly if you mean to reduce the number of records in each reply, or you want to send the reply in pieces, or what you have in mind...

Want to send the reply in pieces. By example i have a file with 1000 records and want to send the data in sets of 100. Something similar (i think) to NetWebBrowse settings / Options when loading method is page and records per page are a defined number.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11204
    • View Profile
Re: Records Paging and JSON
« Reply #3 on: February 10, 2015, 10:36:00 PM »
hi Ura,

>> Want to send the reply in pieces. By example i have a file with 1000 records and want to send the data in sets of 100. Something similar (i think) to NetWebBrowse settings / Options when loading method is page and records per page are a defined number.

This is do'able, but you need to think about your API that you are offering to the user. Remember this is all just a request and a response. If the user wants smaller pieces then you need to give him the opportunity to _ask_ for smaller pieces.

For example at the moment you have a function that says;

"GetMeAllTheRecords".

but maybe it would be better to have something like;

"GetMeAllNewRecords" or "GetMeAllRecordsAfterDateTime" or "GiveMe10RecordsFromID" and so on.

Obviously these aren't the right method names <g> - but the idea is that you give the user some parameters in your current method to ask for a "subset" of everything you have. As long as the user can figure out what they do have, and ask for anything missing, you should be good to go.

Obviously the exact approach will vary depending o your data set, but for "incremental updates" the most common is to stamp records with some sort of date & time of last change, then the client can ask for "everything that has changed since xxx,xxx". Oh with a "max" parameter. So they can ask for "everything that has changed since xxx,xx - max 10 records". You give them the first 10, they then repeat the question using the last received time as the time of their next starting point.

Cheers
Bruce


Cheers
Bruce