SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2011
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    json string in url: urlencode or not?

    Hello,

    I was wondering if you have to urlencode/urldecode a json string that would be sent/retrieved from the url (using $_GET).


  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,198
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    It's a common practice to URL encode anything that is not an alphanumeric or numeric value been added to the URL as a query string, so yes i would recommend you do URL encode your JSON string.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2011
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's going to be very long... base_64 encode/decode would help, wouldn't it? Is it good practice?

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,198
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    If the JSON string is going to get longer then say 300 characters then i would recommend you use $_POST instead of $_GET as it's less overhead for the browser to process

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2011
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In my scenario, javascript has to read the JSON string too. No access to _POST.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •