? AddStringParam use " \" " and/or ' " '

0 favourites
  • 6 posts
  • It would be nice to be able to use ' " ' and/or " \" " at "AddStringParam" and other.

    At moment i have to use for example:

    str("{'name':'"&Reg_NameIN.Text&"','password':'"&SmartFoxServer.EncryptPassword(Reg_PassIN.Text)&"','mail':'"&Reg_MailIN.Text&"'}")

    That's a little crazy to write.

    And in plugin I need to String.replace() ' with " to make a valid json.

    I also can String.replace() ' in construct directly, but that makes it not better...

    I think this also help for other things as json.

    Or did I miss other options?

  • Both of these things are the standard and nature of urls and json formatting.

    Use url encoded characters

    " = %22

    \ = %2f

    Jsons use single quotations for keys so it is a restricted character. You probably will need to continue doing some creative replacing here to bypass this limitation

  • Thanks for reply, but for me it was actually about Constructs->AddStringParam with 'string', not about json.

    I know my english is not very well...

    Conversely, this will work for json, but construct dont accept:

    str('{"name"":"'&Reg_NameIN.Text&'","password":"'&SmartFoxServer.EncryptPassword(Reg_PassIN.Text)&'","mail":"'&Reg_MailIN.Text&'"}')

    Other example for same situation:

    str('He said:"Hello".')

    str("He said:\"Hello\".")

    This wont work in Construct. Is working in JavaScript. Would be nice if Construct accept this.

    Or do you mean something like:

    "{%22name%22%22:%22"&Reg_NameIN.Text&"%22,%22password%22:%22"&

    SmartFoxServer.EncryptPassword(Reg_PassIN.Text)&"%22,%22mail%22:%22"&Reg_MailIN.Text&"%22}"

    I think that's even worse.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • To put a " in construct you need to use ""

    "He said ""hello""."

  • WTF When I watch this, it dizzy me.

    But it seems to work and will make it more simple.

    So "" is like \".

    Thank you much, for this information!

    And with my new sprintf, status is now:

    Tools.sprintf("{""name"":""{0}"",""password"":""{1}"",""mail"":""{2}""}",Reg_NameIN.Text,SmartFoxServer.EncryptPassword(Reg_PassIN.Text),Reg_MailIN.Text)

    Much better, now it is readable and no .replace needed!

    But I think furthermore, would be nice to be able to use. 'He said: "Hello".'

  • Ashley , is there any chance we could have es6 template strings in the editor to avoid this kind of thing?

    maybe for c3?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)