Invalid top-level type in JSON write'

前端 未结 2 828
日久生厌
日久生厌 2021-01-17 11:02

I am passing some parameter to api , to done add to cart function. But when i pass the parameter , it showing the crash Invalid top-level type in JSON write\' i

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-17 11:32

    There is a subtle difference

    Try using this

    JSONSerialization.jsonObject(with: data, options: []) as? [String:AnyObject] 
    

    instead of

    JSONSerialization.data(withJSONObject: data, options: []) as? [String:AnyObject]
    

提交回复
热议问题