[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HTTPAPI and Json



   Mike,
   I agree, but when did IBM launch XML-INTO in RPGLE - 10 years after all
   others so
   if we assume the same speed we will have a JSON-INTO in 10 years ;-)
   I also agree that simple stuff can be covered by simple code, but
   programmers tends
   to persue simple coding examples into the more complex world and then
   they suddenly
   are stucked.�   I have build powerEXT to handle it all, Mihael and Scott has build
   their own based
   on an OO approach, Niels has build it in his own special way and I
   prefer the�   procedural approach. LANSA and Websydian propably has their own hidden
   JSON features
   and so we can go on.
   Another thing is that powerEXT is all build in public RPGLE so I or any
   other are able�   to modify the code and make workarounds of general nonstandard
   miscodings just like many�   javascript interpreters and browsers do.
   �   Here is how I create JSON and read (simple) JSON (as the examples
   requires)�   in powerEXT Core
   setContent('*none');
   jsonNode('*object');
   � jsonNode('*string':'public_key':mykeyfield);
   � jsonNode('*object':'operations');
   � � jsonNode('*string':'token':'[generated token]');
   � � jsonNode('*number':'shop_process_id':'54322');
   � � jsonNode('*string':'currency':'PYG');
   � � jsonNode('*number':'amount':'10330.00');
   � � jsonNode''*string':'additional_data':'017VS ORO000045001');
   � � jsonNode('*string':'description':'Ejemplo de pago');
   � �   jsonNode('*string':'return_url':'[1]http://www.example.com/finish');
   � �   jsonNode('*string':'cancel_url':'[2]http://www.example.com/cancel');
   � jsonEndNode();
   jsonEndNode();
   any data constant can of cource be passed as a value of field as well
   and
   any data passed that contains special characters are automatically
   encoded.
   The JSON object will then be in bufAddr() and the size will be in
   bufSize()
   and can be send by HTTPAPI
   To read this simple JSON object there are two ways - either read it
   directly
   or convert it to XML. Simple JSON is a JSON object that dosn't contains
   array's.
   To read it directly use procedure
   jsonToField(addr:size:varname:[notFoundValue]):
   myKeyField = jsonToField(bufAddr:bufSize:'public_key');
   myCurrency = jsonToField(bufAddr:bufSize:'currency');
   ... etc.
   Since HTTPAPI also can return the result as an address and size it is
   quite simple
   to read the returned JSON that of course also can be read based on
   input from an�   IFS file.�
   On Fri, Sep 27, 2013 at 5:22 PM, Mike Krebs
   <[3]mkrebs@xxxxxxxxxxxxxxxxxx> wrote:

     No problem with the many issues that cry out for a general purpose
     JSON creator/parser. Just like XML, it is easy for the simple stuff
     but gets messy later on when the data gets more complicated.
     But in Raul's case, even though I don't know Spanish, I can see the
     JSON examples are pretty straight forward. The webservice needs to
     receive a simple set of data.

   {
   "public_key": "[public key]",
   "operation": {
   "token": "[generated token]",

     "shop_process_id": 54322,
     "currency": "PYG",
     "amount": "10330.00",
     "additional_data": "017VS ORO000045001",
     "description": "Ejemplo de pago",
     "return_url": "[4]http://www.example.com/finish";,
     "cancel_url": "[5]http://www.example.com/cancel";
     }
     }
     And it is returning two simple strings in the response:
     {
     "status": "success",
     "process_id": "i5fn*lx6niQel0QzWK1g"
     }
     In between, because of the language issue, the process gets fuzzy to
     me. It almost appears that this will take the user to the
     [6]bancard.com.py site and there they would complete the
     transaction. If that is the case, this will be a little harder to
     simulate in HTTPAPI. I think that is the bigger issue for Raul.

   -----Original Message-----
   From: [7]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   [mailto:[8]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Henrik
   Rützou

   Sent: Thursday, September 26, 2013 7:18 PM
   To: HTTPAPI and FTPAPI Projects
   Subject: Re: HTTPAPI and Json

   Mike,
   And please lets us not start a new never ending discussion about if
   special
   characters
   in XML or JSON has to be encoded/decoded.
   In practise (since JSON is JAVASCRIPT object notation) it does allows
   strings like 'Mc'donalds' but
   that has to be encoded 'Mc\'Donalds' or "My nick'name is "Olfert"" that
   has
   to be encoded "My name
   nick'name is \"Olfert\"" - encoding/decoding depends of the starting
   delimiter of the string.
   It also allows JSON node names to be quoted or not such as
   "customernumber"
   : 1234 or
   customernumber : 1234.
   And that is just simple processing of a node and its data where you
   have to
   simulate how
   javascript treats data - teoretical rules or not!
   On Fri, Sep 27, 2013 at 1:33 AM, Henrik Rützou <[9]hr@xxxxxxxxxxxx>
   wrote:
   > Mike,
   >
   > you are quite right, passing JSON back is easy if you are extremely
   good
   > at string handling and
   > decoding since JSON comes in many flavors and is an hirachical data
   > structure.
   >
   > I don't know if Scott's implementation also includes reading of a
   JSON
   > structures otherwise it is
   > just an OO implementation of what already has already been done by
   others
   > (Mihael Schmidt)
   >
   >
   >
   >
   > On Fri, Sep 27, 2013 at 1:04 AM, Mike Krebs
   <[10]mkrebs@xxxxxxxxxxxxxxxxxx>wrote:
   >
   >> I don't read Spanish very well (si senor said like American Speedy
   >> Gonzales�so I can't make out what they are asking you to do but it
   is a
   >> POST of some kind. I don't think you need a web form but maybe
   because it
   >> looks like the web service is written for an interactive website
   update. If
   >> you use a web-like post then EXAMPLE4 not example2 (which release do
   you
   >> have installed?) is where you want to start. Otherwise, just send
   the JSON
   >> as the post data.
   >>
   >> Creating the required JSON looks pretty straight forward. It also
   looks
   >> like the return "codes" will be easy enough to parse but you might
   look for
   >> some help with that using powerEXT or YAJL which has been ported to
   IBMi (
   >> [11]http://www.scottklement.com/yajl/).
   >>
   >>
   >>
   >> -----Original Message-----
   >> From: [12]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:
   >> [13]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Henrik
   Rützou
   >> Sent: Thursday, September 26, 2013 4:54 PM
   >> To: HTTPAPI and FTPAPI Projects
   >> Subject: Re: HTTPAPI and Json
   >>
   >> Hi,
   >>
   >> the services probably work as a JSON web service, and yous you can
   use
   >> HTTPAPI
   >> for that.
   >>
   >> You can either concatinate the request in a field and send it like
   XML,
   >> the
   >> problem is
   >> when you recieve JSON back.
   >>
   >> You can combine HTTPAPI and my powerEXT Core service program that
   has I/O
   >> support for JSON
   >>
   >>
   >> On Thu, Sep 26, 2013 at 10:41 PM, Raul A. Jager W.
   <[14]raul@xxxxxxxxxx>
   >> wrote:
   >>
   >> > I need to comunicate with Bancard for credit card payment, they
   >> installed
   >> > a new sistem that uses json as protocol, and the manual requests a
   >> "post"
   >> > whit the data in json format instead of the usual webform.
   >> >
   >> > In the example2, the program builds a webform and sends it with
   >> > http_url_post.
   >> > Can I build the json in a char variable and send it the same way?
   >> >
   >> > A full description of the expected protocol is in:
   >> >
   [15]https://www.bancard.com.py/**docs/Manual_Tecnico_E-**Commerce.pdf<
   >> [16]https://www.bancard.com.py/docs/Manual_Tecnico_E-Commerce.pdf>
   >> >
   >> > Here I copied a small part where it explains that we must POST the
   Json,
   >> > later on it gives all the detial of the data to send with each
   request.
   >> >
   >> > ______________________________**______________________________**
   >> > ______________________________**___________
   >> > Peticiones realizadas por el portal a VPOS
   >> > Las peticiones serán realizadas por POST a una interfaz REST
   >> > public_key Clave pública del portal. En el caso de la
   confirmación, la
   >> key
   >> > enviada es
   >> > también la del portal al cual se env�.
   >> > Datos de la operación que se va a llevar a cabo.
   >> > {
   >> > "public_key": "[public key]",
   >> > "operation": {
   >> > "token": "[generated token]",
   >> > ...
   >> > }
   >> > }
   >> >
   >> >
   >> > ------------------------------**------------------------------**
   >> > -----------
   >> > This is the FTPAPI mailing list. �To unsubscribe, please go to:
   >> > [17]http://www.scottklement.com/**mailman/listinfo/ftpapi<
   >> [18]http://www.scottklement.com/mailman/listinfo/ftpapi>
   >> > ------------------------------**------------------------------**
   >> > -----------
   >> >
   >>
   >>
   >>
   >> --
   >> Regards,
   >> Henrik Rützou
   >>
   >> �[19]http://powerEXT.com <[20]http://powerext.com/>
   >>
   -----------------------------------------------------------------------
   >> This is the FTPAPI mailing list. �To unsubscribe, please go to:
   >> [21]http://www.scottklement.com/mailman/listinfo/ftpapi
   >>
   -----------------------------------------------------------------------
   >>
   >
   >
   >
   > --
   > Regards,
   > Henrik Rützou
   >

     > �[22]http://powerEXT.com <[23]http://powerext.com/>

   >
   >
   >
   --
   Regards,
   Henrik Rützou
   �[24]http://powerEXT.com <[25]http://powerext.com/>
   -----------------------------------------------------------------------
   This is the FTPAPI mailing list. �To unsubscribe, please go to:
   [26]http://www.scottklement.com/mailman/listinfo/ftpapi
   -----------------------------------------------------------------------

   --
   Regards,
   Henrik Rützou
   �   [27]http://powerEXT.com
   �
References

   1. http://www.example.com/finish'
   2. http://www.example.com/cancel'
   3. mailto:mkrebs@xxxxxxxxxxxxxxxxxx
   4. http://www.example.com/finish
   5. http://www.example.com/cancel
   6. http://bancard.com.py/
   7. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   8. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   9. mailto:hr@xxxxxxxxxxxx
  10. mailto:mkrebs@xxxxxxxxxxxxxxxxxx
  11. http://www.scottklement.com/yajl/
  12. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
  13. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
  14. mailto:raul@xxxxxxxxxx
  15. https://www.bancard.com.py/**docs/Manual_Tecnico_E-**Commerce.pdf
  16. https://www.bancard.com.py/docs/Manual_Tecnico_E-Commerce.pdf
  17. http://www.scottklement.com/**mailman/listinfo/ftpapi
  18. http://www.scottklement.com/mailman/listinfo/ftpapi
  19. http://powerEXT.com/
  20. http://powerext.com/
  21. http://www.scottklement.com/mailman/listinfo/ftpapi
  22. http://powerEXT.com/
  23. http://powerext.com/
  24. http://powerEXT.com/
  25. http://powerext.com/
  26. http://www.scottklement.com/mailman/listinfo/ftpapi
  27. http://powerext.com/
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------