There are 3 string variables
public var userLoginId : String?
public var searchString : String?
public var tableName : String?
I have a dictionary:
let dict = ["userLoginId" : userLoginId, "searchString" : searchString,"tableName" : tableName]
Now I serialize it by JSON:
let data = try! JSONSerialization.data(withJSONObject: dict, options :[])
let jsonstring = String(data:data, encoding:.utf8)!
In jsonstring
, every time I get an unordered JSON like below:
"{"tableName":"null","userLoginId":"Dilip","searchString":"Tata"}"
How can I get in the same format in which I assigned value to dictionary?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…