简体   繁体   中英

How to return simplejson in Python

I am a noob and I am working on a Python project that uses json. My goal is to call an object ("object.json()") and get the data.

The only thing is I can only import simplejson and not import json .

How do I call on an object with simplejson eg("object.simplejson()) <----- Obviously not right but this is just an example.

Btw I am using MAC Sierra 10.12.6

You just need to use the dumps method:

import simplejson
encoded = simplejson.dumps(myobject)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM