Web Connection
JSON to download
Gravatar is a globally recognized avatar based on your email address. JSON to download
  Luca
  All
  Mar 6, 2017 @ 05:10am

Dear Rick, I made a REST service following your step by step tutorial.
All is right, but I have a problem when I pass a cursor too long with

	RETURN "cursor:Query"

Please is there the possibility to convert the result of a query into JSON format (or any other format) and to write the file on disk in order to transmit it with classic download procedure?
I tried to follow your example with

JsonService.IsRawResponse = .T.

but unfortunately without success.
Many thanks for support

Gravatar is a globally recognized avatar based on your email address. re: JSON to download
  Rick Strahl
  Luca
  Mar 6, 2017 @ 12:29pm

FIrst off: Don't do that 😃 Do you really need to send too much data over the wire that you exceed 16 megs? If you do this isn't a good use case for a service method and you should probably allow your customer to download the data directly (ie. raw Response and Response.TransmitFile()/DownloadFile()).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: JSON to download
  Luca
  Rick Strahl
  Mar 7, 2017 @ 12:30am

Dear Rick,
I said it to the customer but he would like to download a JSON file with TransmitFile() when it would be too long to have a direct JSON response from REST service.
So, is it possible to create a JSON file on server and send it with TransmitFile for download?
Sincerely

Gravatar is a globally recognized avatar based on your email address. re: JSON to download
  Rick Strahl
  Luca
  Mar 8, 2017 @ 03:21pm

I don't think you can use wwJsonSerializer (or the REST Service) to create JSON larger than the 16 meg FoxPro string limit. JSON is generated to string and so is subject to the 16 meg limit.

16 meg is a lot of data and you'll want to think carefully if you want to send that much data over the wire in this format. Just generating that data is likely going to be pretty darn slow and even slower to parse on the other end. If you're downloading files or more complete data consider just sending the zipped up files.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: JSON to download
  Luca
  Rick Strahl
  Mar 8, 2017 @ 09:44pm

Dear Rick,
I had not realized that the problem was due to the 16 Mb string limit, even by saving on server.
So I will look for a different response in case of results too large.
Many thanks again, the REST service is a very useful and flexible tool.

Gravatar is a globally recognized avatar based on your email address. re: JSON to download
  Rick Strahl
  Luca
  Mar 9, 2017 @ 11:58am

Yeah it might be a good idea to add an option to generate output to a file, but then again I honestly don't think it's a good idea to generate JSON output that large. If you need to send that much data it's better to find some other way to send it to the client (like as a file download).ß

+++ Rick ---

© 1996-2024