1

I'm getting JSON data with different data types. I want to convert a string '22' into integer 22.

I have this code: jData["ID"]

I have tried: let id = jData["ID"]! as Int

but it gave me an error

EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT,subcode=0xdefe)

Can someone please solve my problem...

Thanks

Mr.KLD
  • 2,632
  • 2
  • 16
  • 26

1 Answers1

1

Pass jData["ID"] as string and use toInt():

let id = String(jData["ID"]).toInt()
nicael
  • 18,550
  • 13
  • 57
  • 90