Page 1 of 1

Dynamic Auto-Complete By JSON

Posted: Thu Sep 18, 2014 8:17 am
by dieter
Hello,
i want to create a webservice which gives data to a combo box. Is there an example which data format the webservice has to deliver? In the documentation i found an example like this:

Code: Select all

"The choices URL property allows you to use an external program to return your choice options and values by passing them using JSON formatting".
{
     "success":true,
     "response":[
          new Option("Dishes and Cups","18"),
          new Option("Soaps","14")
     ]
}
I am not a web specialist, but i think that this in no JSON format. It seems to be a mixture of JSON and Javascript. Is this format the only way to get choices and values via an url? (In this case i have to extend my JSON tools because they can only create pure JSON Objects).



P.S.
I just extended my JSON Tools, so now the tools can create this format. It works.
Dieter.



Dieter

Re: Dynamic Auto-Complete By JSON

Posted: Thu Sep 18, 2014 11:24 am
by Scott Klement
Yes, unfortunately they used JavaScript code for this instead of JSON.

Personally, I'd rather have plain JSON for the messages exchanged between the server and the browser, but unfortunately, in this case they didn't do that... they used some JavaScript code in the JSON.

Re: Dynamic Auto-Complete By JSON

Posted: Thu Sep 18, 2014 12:00 pm
by dieter
Thank you for your answer.
I agree with you. Yesterday i was happy because my RPG-tools could write pure JSON without failures. Today i had to change my tools to write "unpure" JSON.

But this is no problem, i could encapsulate the format inside my tools. First i thought that i had not understand the documentation. But your answer gave me the safety that i am right.

Thank you.

Another question. The format in the example is:

Code: Select all

{
     "success":true,
     "response":[
          new Option("Dishes and Cups","18"),
          new Option("Soaps","14")
     ]
}
Is "18" a string or is it a string representation of a number? Would the following be correct: (The numbers are not in quotation marks):

Code: Select all

{
     "success":true,
     "response":[
          new Option("salary",1234.56),
          new Option("tax",234.56)
     ]
}
Is a string the only datatype or are there another types like numbers, dates, booleans?

Dieter

Re: Dynamic Auto-Complete By JSON

Posted: Fri Sep 19, 2014 8:23 am
by aj_400
Hi Dieter,

i have created this using the Universal DSPF and it works very fine.

You can see it, using this link (in Geman) : http://forum.taskforce-it.de/viewtopic.php?f=4&t=69

Regards
Andreas

Re: Dynamic Auto-Complete By JSON

Posted: Fri Sep 19, 2014 9:37 am
by dieter
Thank you, Andreas.

Your example is very nice. My problem was the understanding of the format. In the documentation the format was called "JSON". But the format is not JSON, it is JavaScript.

Regards,
Dieter