Return to Video

Escaping JSON in Python Solution - Web Development

  • 0:00 - 0:06
    The correct answer is blah equals the
  • 0:06 - 0:12
    list "one, 2 and now "th\" r\"
  • 0:12 - 0:18
    ee"]}. The main distinction between a Python object and a JSON representation of
  • 0:18 - 0:22
    a very similar object is that JSON has to use double quotes to
  • 0:22 - 0:26
    delineate a string. It can't use single quotes like Python does. So, you must
  • 0:26 - 0:29
    escape any internal double quotes. Alright, so this is basic JSON.
  • 0:29 - 0:33
    And as we've seen it maps very nicely to Python data structures,
  • 0:33 - 0:36
    assuming you're using integers and floats and strings. If you want
  • 0:36 - 0:39
    to map a more complicated Python structure 2 JSON, let's say you're
  • 0:39 - 0:41
    doing an object or maybe a date time or some other
  • 0:41 - 0:44
    things, the JSON dumps function isn't going to work for you. You're
  • 0:44 - 0:47
    going to have to actually convert those by hand to a simple
  • 0:47 - 0:51
    data structure made up of dictionaries, and lists, and integers, and strings
  • 0:51 - 0:53
    so that we can output it properly.
Title:
Escaping JSON in Python Solution - Web Development
Description:

more » « less
Video Language:
English
Team:
Udacity
Project:
CS253 - Web Development
Duration:
0:53

English subtitles

Revisions Compare revisions