Welcome, Guest
Username: Password: Remember me
Discussions for CodeTyphon Object Pascal Programming Language
  • Page:
  • 1

TOPIC:

Command line with JSON in CT 5.5 8 years 11 months ago #8697

  • Md. Shariful Alam Khan
  • Md. Shariful Alam Khan's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 111
  • Thank you received: 0
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.

Command line with JSON in CT 5.5 8 years 11 months ago #8700

  • Tony_O_Gallos
  • Tony_O_Gallos's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Ελεύθερο λογισμικό ή θάνατος
  • Posts: 84
  • Thank you received: 23
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.

Command line with JSON in CT 5.5 8 years 11 months ago #8701

  • Md. Shariful Alam Khan
  • Md. Shariful Alam Khan's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 111
  • Thank you received: 0
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.

  • Page:
  • 1