Swift Parse JSON Error : No value associated with key CodingKeys(stringValue: "_sourceSwift : The data couldn’t be read because it isn’t in the correct formatWhy can't Python parse this JSON data?Parse JSON in JavaScript?Parse nested JSON in Swift 4.1I am try to fetch the data from sql server through WCF serviceJSON Parsing Swift 4Parsing the JSON iOS-Swiftswift parsing json No value associated with key CodingKeys(stringValue: “id”, intValue: nil) (“id”)swift parse json error “No value associated with key CodingKeys(stringValue: ”id“, intValue: nil) (”id“).”NSObject Decodable same valueNot able to parse data using Codable and Alamofire 3.0
How do I tell my boss that I'm quitting in 15 days (a colleague left this week)
Origin of pigs as a species
How to make money from a browser who sees 5 seconds into the future of any web page?
Is there anyway, I can have two passwords for my wi-fi
Can I run 125kHz RF circuit on a breadboard?
Did I make a mistake by ccing email to boss to others?
Sound waves in different octaves
Deciphering cause of death?
Grepping string, but include all non-blank lines following each grep match
Make a Bowl of Alphabet Soup
Pre-Employment Background Check With Consent For Future Checks
How to understand "he realized a split second too late was also a mistake"
Identifying "long and narrow" polygons in with PostGIS
Do you waste sorcery points if you try to apply metamagic to a spell from a scroll but fail to cast it?
How do I prevent inappropriate ads from appearing in my game?
Difference between shutdown options
How to get directions in deep space?
Proving an identity involving cross products and coplanar vectors
What does "tick" mean in this sentence?
What is this high flying aircraft over Pennsylvania?
Isometric embedding of a genus g surface
Why does the Persian emissary display a string of crowned skulls?
How many people need to be born every 8 years to sustain population?
Are inadvertent environmental catastrophes also examples of natural selection?
Swift Parse JSON Error : No value associated with key CodingKeys(stringValue: "_source
Swift : The data couldn’t be read because it isn’t in the correct formatWhy can't Python parse this JSON data?Parse JSON in JavaScript?Parse nested JSON in Swift 4.1I am try to fetch the data from sql server through WCF serviceJSON Parsing Swift 4Parsing the JSON iOS-Swiftswift parsing json No value associated with key CodingKeys(stringValue: “id”, intValue: nil) (“id”)swift parse json error “No value associated with key CodingKeys(stringValue: ”id“, intValue: nil) (”id“).”NSObject Decodable same valueNot able to parse data using Codable and Alamofire 3.0
I am attempting to parse the following json data:
Below is my struct:
struct Album: Decodable
var source: [Sourcet]
enum CodingKeys: String, CodingKey
case source = "_source"
struct Sourcet: Decodable
var nome, endereco, uf, cidade, bairro: String
let response = try JSONDecoder().decode(Album.self, from: data)
I continue getting the error:
keyNotFound(CodingKeys(stringValue: "_source", intValue: nil),
Swift.DecodingError.Context(codingPath: [], debugDescription: "No
value associated with key CodingKeys(stringValue: "_source",
intValue: nil) ("_source").", underlyingError: nil))
Is this due to the json information being an array?.How would I be able to parse this information?
json swift alamofire jsonparser
add a comment |
I am attempting to parse the following json data:
Below is my struct:
struct Album: Decodable
var source: [Sourcet]
enum CodingKeys: String, CodingKey
case source = "_source"
struct Sourcet: Decodable
var nome, endereco, uf, cidade, bairro: String
let response = try JSONDecoder().decode(Album.self, from: data)
I continue getting the error:
keyNotFound(CodingKeys(stringValue: "_source", intValue: nil),
Swift.DecodingError.Context(codingPath: [], debugDescription: "No
value associated with key CodingKeys(stringValue: "_source",
intValue: nil) ("_source").", underlyingError: nil))
Is this due to the json information being an array?.How would I be able to parse this information?
json swift alamofire jsonparser
Possible duplicate of Swift : The data couldn’t be read because it isn’t in the correct format
– staticVoidMan
Mar 8 at 11:19
add a comment |
I am attempting to parse the following json data:
Below is my struct:
struct Album: Decodable
var source: [Sourcet]
enum CodingKeys: String, CodingKey
case source = "_source"
struct Sourcet: Decodable
var nome, endereco, uf, cidade, bairro: String
let response = try JSONDecoder().decode(Album.self, from: data)
I continue getting the error:
keyNotFound(CodingKeys(stringValue: "_source", intValue: nil),
Swift.DecodingError.Context(codingPath: [], debugDescription: "No
value associated with key CodingKeys(stringValue: "_source",
intValue: nil) ("_source").", underlyingError: nil))
Is this due to the json information being an array?.How would I be able to parse this information?
json swift alamofire jsonparser
I am attempting to parse the following json data:
Below is my struct:
struct Album: Decodable
var source: [Sourcet]
enum CodingKeys: String, CodingKey
case source = "_source"
struct Sourcet: Decodable
var nome, endereco, uf, cidade, bairro: String
let response = try JSONDecoder().decode(Album.self, from: data)
I continue getting the error:
keyNotFound(CodingKeys(stringValue: "_source", intValue: nil),
Swift.DecodingError.Context(codingPath: [], debugDescription: "No
value associated with key CodingKeys(stringValue: "_source",
intValue: nil) ("_source").", underlyingError: nil))
Is this due to the json information being an array?.How would I be able to parse this information?
json swift alamofire jsonparser
json swift alamofire jsonparser
asked Mar 7 at 2:39
Krunal NagvadiaKrunal Nagvadia
13014
13014
Possible duplicate of Swift : The data couldn’t be read because it isn’t in the correct format
– staticVoidMan
Mar 8 at 11:19
add a comment |
Possible duplicate of Swift : The data couldn’t be read because it isn’t in the correct format
– staticVoidMan
Mar 8 at 11:19
Possible duplicate of Swift : The data couldn’t be read because it isn’t in the correct format
– staticVoidMan
Mar 8 at 11:19
Possible duplicate of Swift : The data couldn’t be read because it isn’t in the correct format
– staticVoidMan
Mar 8 at 11:19
add a comment |
1 Answer
1
active
oldest
votes
Your struct Album
is wrong and you're parsing Album.self
single object instead of array.
Try below code :
struct Album: Decodable
var source: Sourcet // change array to single object
enum CodingKeys: String, CodingKey
case source = "_source"
struct Sourcet: Decodable
var nome, uf : String
To parse json in model :
do
let response = try JSONDecoder().decode([Album].self, from: data)
for item in response
print(item.source.nome)
catch
print("Error: ",error)
it's not work for me
– Krunal Nagvadia
Mar 7 at 15:35
use edit option and past your full tried code.
– Pratik Prajapati
Mar 8 at 3:12
it is Rest Api then Above process work?
– Krunal Nagvadia
Mar 8 at 3:46
what error are you getting ?
– Pratik Prajapati
Mar 8 at 4:41
can you please write the complete code for call the above json. It is REST Api with Post method
– Krunal Nagvadia
Mar 8 at 4:44
|
show 6 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55035215%2fswift-parse-json-error-no-value-associated-with-key-codingkeysstringvalue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your struct Album
is wrong and you're parsing Album.self
single object instead of array.
Try below code :
struct Album: Decodable
var source: Sourcet // change array to single object
enum CodingKeys: String, CodingKey
case source = "_source"
struct Sourcet: Decodable
var nome, uf : String
To parse json in model :
do
let response = try JSONDecoder().decode([Album].self, from: data)
for item in response
print(item.source.nome)
catch
print("Error: ",error)
it's not work for me
– Krunal Nagvadia
Mar 7 at 15:35
use edit option and past your full tried code.
– Pratik Prajapati
Mar 8 at 3:12
it is Rest Api then Above process work?
– Krunal Nagvadia
Mar 8 at 3:46
what error are you getting ?
– Pratik Prajapati
Mar 8 at 4:41
can you please write the complete code for call the above json. It is REST Api with Post method
– Krunal Nagvadia
Mar 8 at 4:44
|
show 6 more comments
Your struct Album
is wrong and you're parsing Album.self
single object instead of array.
Try below code :
struct Album: Decodable
var source: Sourcet // change array to single object
enum CodingKeys: String, CodingKey
case source = "_source"
struct Sourcet: Decodable
var nome, uf : String
To parse json in model :
do
let response = try JSONDecoder().decode([Album].self, from: data)
for item in response
print(item.source.nome)
catch
print("Error: ",error)
it's not work for me
– Krunal Nagvadia
Mar 7 at 15:35
use edit option and past your full tried code.
– Pratik Prajapati
Mar 8 at 3:12
it is Rest Api then Above process work?
– Krunal Nagvadia
Mar 8 at 3:46
what error are you getting ?
– Pratik Prajapati
Mar 8 at 4:41
can you please write the complete code for call the above json. It is REST Api with Post method
– Krunal Nagvadia
Mar 8 at 4:44
|
show 6 more comments
Your struct Album
is wrong and you're parsing Album.self
single object instead of array.
Try below code :
struct Album: Decodable
var source: Sourcet // change array to single object
enum CodingKeys: String, CodingKey
case source = "_source"
struct Sourcet: Decodable
var nome, uf : String
To parse json in model :
do
let response = try JSONDecoder().decode([Album].self, from: data)
for item in response
print(item.source.nome)
catch
print("Error: ",error)
Your struct Album
is wrong and you're parsing Album.self
single object instead of array.
Try below code :
struct Album: Decodable
var source: Sourcet // change array to single object
enum CodingKeys: String, CodingKey
case source = "_source"
struct Sourcet: Decodable
var nome, uf : String
To parse json in model :
do
let response = try JSONDecoder().decode([Album].self, from: data)
for item in response
print(item.source.nome)
catch
print("Error: ",error)
edited Mar 8 at 6:10
answered Mar 7 at 3:01
Pratik PrajapatiPratik Prajapati
812721
812721
it's not work for me
– Krunal Nagvadia
Mar 7 at 15:35
use edit option and past your full tried code.
– Pratik Prajapati
Mar 8 at 3:12
it is Rest Api then Above process work?
– Krunal Nagvadia
Mar 8 at 3:46
what error are you getting ?
– Pratik Prajapati
Mar 8 at 4:41
can you please write the complete code for call the above json. It is REST Api with Post method
– Krunal Nagvadia
Mar 8 at 4:44
|
show 6 more comments
it's not work for me
– Krunal Nagvadia
Mar 7 at 15:35
use edit option and past your full tried code.
– Pratik Prajapati
Mar 8 at 3:12
it is Rest Api then Above process work?
– Krunal Nagvadia
Mar 8 at 3:46
what error are you getting ?
– Pratik Prajapati
Mar 8 at 4:41
can you please write the complete code for call the above json. It is REST Api with Post method
– Krunal Nagvadia
Mar 8 at 4:44
it's not work for me
– Krunal Nagvadia
Mar 7 at 15:35
it's not work for me
– Krunal Nagvadia
Mar 7 at 15:35
use edit option and past your full tried code.
– Pratik Prajapati
Mar 8 at 3:12
use edit option and past your full tried code.
– Pratik Prajapati
Mar 8 at 3:12
it is Rest Api then Above process work?
– Krunal Nagvadia
Mar 8 at 3:46
it is Rest Api then Above process work?
– Krunal Nagvadia
Mar 8 at 3:46
what error are you getting ?
– Pratik Prajapati
Mar 8 at 4:41
what error are you getting ?
– Pratik Prajapati
Mar 8 at 4:41
can you please write the complete code for call the above json. It is REST Api with Post method
– Krunal Nagvadia
Mar 8 at 4:44
can you please write the complete code for call the above json. It is REST Api with Post method
– Krunal Nagvadia
Mar 8 at 4:44
|
show 6 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55035215%2fswift-parse-json-error-no-value-associated-with-key-codingkeysstringvalue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of Swift : The data couldn’t be read because it isn’t in the correct format
– staticVoidMan
Mar 8 at 11:19