× Discussions for CodeTyphon Object Pascal Programming Language

Question Command line with JSON in CT 5.5

  • Md. Shariful Alam Khan
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
4 years 7 months ago #8697 by Md. Shariful Alam Khan
Command line with JSON in CT 5.5 was created by Md. Shariful Alam Khan
I am trying to develop a console application which is a console application. In that application I need one param which must be as JSON. The value can be as {"intype":"1","name":"John O'Neil","val":"Test123","ordnr":"Invoice # 123","trannr":"000001675611"}. On that, if I call GetOptionValue('myparam') I receive as {"intype":"1","name":"John ONeil,val:Test123,ordnr:Invoice. How can I get full value as it is? As I have to parse the JSON. The single quote of name is breaking the whole thing. This is how I am executing it:
./project1 -tranvalues '{"intype":"1","name":"John O'Neil","val":"Test123","ordnr":"Invoice # 123","trannr":"000001675611"}'

Please Log in or Create an account to join the conversation.

  • Tony_O_Gallos
  • Tony_O_Gallos's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Ελεύθερο λογισμικό ή θάνατος
More
4 years 7 months ago #8700 by Tony_O_Gallos
Replied by Tony_O_Gallos on topic Command line with JSON in CT 5.5
In your JSON string you could replace your single quote in "John O'Neil" by:
- 2 single quotes
- an escape sequence \'
- a unicode \u0027
It requires to prepare the JSON string before to use it as parameter of course :/

Please Log in or Create an account to join the conversation.

  • Md. Shariful Alam Khan
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
4 years 7 months ago #8701 by Md. Shariful Alam Khan
Replied by Md. Shariful Alam Khan on topic Command line with JSON in CT 5.5
This is what my client said:
"There are standards for sending data in JSON based on URL Encoding. Your system has to support those standards. Using \'' etc. is not to the standards."
So in JSON I can force my client to put
- 2 single quotes
- an escape sequence \'

How can I convert that single quote? As in GetOptionValue when ever single quote find it breaks whole line.
Sternas Stefanos Please help. Where are you?

Please Log in or Create an account to join the conversation.