Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Flask Basics Character Builder Create a JSON String

Callum Anderson
Callum Anderson
9,249 Points

Wording of question is confusing for me. JSON Strings in Flask Basics

Feeling a bit miffed as I'm not understanding and would like a second perspective! been enjoying this so far and would like to continue. Should be able to view the challenge to see the question and such on the top right.

json_string.py
import json

def to_json():

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Callum Anderson ! Looks like you've got started pretty well. Your function definition is going to need a parameter to hold what we're passing in. In this case, it's asking you to convert it to a string. So you will need the .dumps() method of json here.

import json

def to_json(py_dict): # accept a Python object
    return json.dumps(py_dict)  # convert the Python object (dict) to a string and return it

Hope this helps! :sparkles:

Callum Anderson
Callum Anderson
9,249 Points

I understood the library but was totally puzzled how to go about it. Thanks so much!!