0

I am trying to parse json string to HashMap using json.decode(myString) but I am getting an error.

The following is my json string:

{
 'id':'5043' , 
 'artist':'Axwell Λ Ingrosso' ,
 'title':'More Than You Know' ,
 'displayName':'FDM Axwell Ingrosso.mp3' ,
 'duration':'203050',
 'path':'/storage/emulated/0/UCDownloads/FDM_Axwell_Ingrosso.mp3' 
 }

I am using jsong.decode(aboveString) to convert but I am getting the following error:

FormatException: Unexpected character (at character 2) {'id':'5043' ,'artist':'Axwell Λ Ingrosso' ,'title':'More Than You Know'

2
  • 1
    Some JSON parsers can deal with single quotes, far from all though so I would think using double quotes may solve your problem. Commented Jun 16, 2019 at 7:07
  • As already said, JSON does not support single quotes. However, if you can't change the data format, you can use a yaml parser instead. Commented Jun 16, 2019 at 7:25

1 Answer 1

1

As far as i can tell, you should change all your single quotes to double quotes.

{
   'person': 'Λ'
}

The above gives me an error, however, this does not:

{
   "person": "Λ"
}
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.