4

I know this kind of question has been asked before but I am not able to find solution for my problem

My function is returning me unicode in this format

{"set_id": "Rome", "group": "human", "attachments": null, , "object_type": "Prop", "attached": null, "tag_id": "prop", "Double Click": "reference", "files": "/makeup/Data/weapons/rifle", "source": "cupid", "attachment_label": null, "require_attachment": true, "rate": "high", "location": "/set2/ep1/Objects/weapons/machineguns/gun.txt", "attachment_type": null, "icon_path": "/resource/asset_manager/icons/rifle.bmp"}

while checking with type it shows it is <type 'unicode'>

I tried with ast.literal_eval(myver) but no luck which are other ways to convert it to python dictionary?

3
  • 1
    That looks like a JSON-String to me. Have you tried import json; json.loads(myver)? Commented Aug 17, 2017 at 15:45
  • @Felk This is invalid JSON. Commented Aug 17, 2017 at 15:48
  • 1
    The example contains this bit: ... null, , "object_type": .... That double comma indeed is invalid JSON, but it is unclear if OP meant that to be there Commented Aug 17, 2017 at 15:52

1 Answer 1

1

This looks like JSON. You might want to convert it to a python dict using python's inbuilt json module:

import json    
data = json.loads(myver)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.