jsonencoder Questions
1
I am having a hard time preserving the order of keys in a JSON object stored in a Django JSONField. I have tried using a custom encoder and decoder as per the docs, but the JSON object keeps re-ord...
Danella asked 10/12, 2020 at 10:54
1
Solved
struct TestEnc: Codable {
var date = Date()
}
let encoder = JSONEncoder()
let tenc = TestEnc()
let jsonData = try encoder.encode(tenc)
let json = String(data: jsonData, encoding: String.Encoding.u...
Andreasandree asked 5/9, 2019 at 22:26
2
I am just curious how can I encode a dictionary with String key and Encodable value into JSON.
For example:
let dict: [String: Encodable] = [
"Int": 1,
"Double": 3.14,
"Bool": false,
"String"...
Demilitarize asked 20/7, 2018 at 16:58
2
Solved
I am trying to serialize a struct to a String using Swift 4's Encodable+JSONEncoder. The object can hold heterogenous values like String, Array, Date, Int etc.
The used approach works fine with t...
Felten asked 7/2, 2018 at 7:55
2
I want to encode Dictionary to json with JSONEncoder.
It seems like a Request, receive a dictionary as parameter and encode it to json as http body.
The code is looks like this:
let dict = ["name"...
Sonyasoo asked 31/1, 2018 at 14:6
2
Solved
I'm looking to store models objects in a Dictionary and would like to serialize the whole dictionary using JSONEncoder into data and subsequently into a string and save it.
The idea is to use Swif...
Eratosthenes asked 20/1, 2018 at 16:21
2
Solved
var test = [String : String] ()
test["title"] = "title"
test["description"] = "description"
let encoder = JSONEncoder()
let json = try? encoder.encode(test)
How can I see the output of the json?...
Colour asked 10/7, 2017 at 18:33
1
© 2022 - 2025 — McMap. All rights reserved.