TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Oyedepo Olufemi
1.4k
334
29.6k
Need help deserializing a json response
Aug 4 2020 1:59 AM
Hello everyone,
Ive been stucked on this for quite some time, kindly help look into this, I can't seem to pick out what the error is here....
{ "code": 500, "message": "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'ChakaIntegration.API.Models.Response.Instruments.InstrumentsAnalytics' because the type requires a JSON object
(e.g. {\"name\":\"value\"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array.
JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath 'data', line 1, position 45.", "data": null, "success": false }
Here is my json:
{
"code": "200",
"message": "Successful",
"data": {
"code": "200",
"message": "Successful",
"data": [
{
"consensusEndDate": null,
"consensusStartDate": 1596153600000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 23,
"ratingHold": 8,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.434211,
"ratingSell": 2,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1596067200000,
"consensusStartDate": 1595376000000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 23,
"ratingHold": 8,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.447368,
"ratingSell": 3,
"ratingUnderweight": 1
},
{
"consensusEndDate": 1595289600000,
"consensusStartDate": 1594944000000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 23,
"ratingHold": 9,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.421053,
"ratingSell": 2,
"ratingUnderweight": 1
},
{
"consensusEndDate": 1594857600000,
"consensusStartDate": 1594598400000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 23,
"ratingHold": 10,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.435897,
"ratingSell": 2,
"ratingUnderweight": 1
},
{
"consensusEndDate": 1594512000000,
"consensusStartDate": 1594166400000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 23,
"ratingHold": 11,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.45,
"ratingSell": 2,
"ratingUnderweight": 1
},
{
"consensusEndDate": 1594080000000,
"consensusStartDate": 1591920000000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 23,
"ratingHold": 11,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.4375,
"ratingSell": 1,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1591833600000,
"consensusStartDate": 1591660800000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 24,
"ratingHold": 11,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.426829,
"ratingSell": 1,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1591574400000,
"consensusStartDate": 1589500800000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 24,
"ratingHold": 10,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.45122,
"ratingSell": 2,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1589414400000,
"consensusStartDate": 1589328000000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 25,
"ratingHold": 10,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.440476,
"ratingSell": 2,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1589241600000,
"consensusStartDate": 1588896000000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 24,
"ratingHold": 10,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.45122,
"ratingSell": 2,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1588809600000,
"consensusStartDate": 1588291200000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 25,
"ratingHold": 10,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.440476,
"ratingSell": 2,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1588204800000,
"consensusStartDate": 1587427200000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 25,
"ratingHold": 9,
"ratingNone": 0,
"ratingOverweight": 3,
"ratingScaleMark": 1.426829,
"ratingSell": 2,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1587340800000,
"consensusStartDate": 1586995200000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 26,
"ratingHold": 9,
"ratingNone": 0,
"ratingOverweight": 2,
"ratingScaleMark": 1.414634,
"ratingSell": 2,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1586908800000,
"consensusStartDate": 1586822400000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 26,
"ratingHold": 10,
"ratingNone": 0,
"ratingOverweight": 2,
"ratingScaleMark": 1.390244,
"ratingSell": 1,
"ratingUnderweight": 2
},
{
"consensusEndDate": 1586736000000,
"consensusStartDate": 1586304000000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 26,
"ratingHold": 11,
"ratingNone": 0,
"ratingOverweight": 2,
"ratingScaleMark": 1.378049,
"ratingSell": 1,
"ratingUnderweight": 1
},
{
"consensusEndDate": 1586217600000,
"consensusStartDate": 1586131200000,
"corporateActionsAppliedDate": 1402272000000,
"ratingBuy": 26,
"ratingHold": 10,
"ratingNone": 0,
"ratingOverweight": 2,
"ratingScaleMark": 1.3625,
"ratingSell": 1,
"ratingUnderweight": 1
}
],
"success": true
},
"success": true
}
And here are my POCO Classes:
public
class
InstrumentsAnalyticsResponse
{
[JsonProperty(
"code"
)]
public
long
Code {
get
;
set
; }
[JsonProperty(
"message"
)]
public
string
Message {
get
;
set
; }
[JsonProperty(
"data"
)]
public
InstrumentAnalytics Data {
get
;
set
; }
[JsonProperty(
"success"
)]
public
bool
Success {
get
;
set
; }
}
public
class
InstrumentAnalytics
{
[JsonProperty(
"code"
)]
public
long
Code {
get
;
set
; }
[JsonProperty(
"message"
)]
public
string
Message {
get
;
set
; }
[JsonProperty(
"data"
)]
public
List<AnalyticsData> Data {
get
;
set
; }
[JsonProperty(
"success"
)]
public
bool
Success {
get
;
set
; }
}
public
class
AnalyticsData
{
[JsonProperty(
"consensusEndDate"
)]
public
long
? ConsensusEndDate {
get
;
set
; }
[JsonProperty(
"consensusStartDate"
)]
public
long
ConsensusStartDate {
get
;
set
; }
[JsonProperty(
"corporateActionsAppliedDate"
)]
public
long
CorporateActionsAppliedDate {
get
;
set
; }
[JsonProperty(
"ratingBuy"
)]
public
long
RatingBuy {
get
;
set
; }
[JsonProperty(
"ratingHold"
)]
public
long
RatingHold {
get
;
set
; }
[JsonProperty(
"ratingNone"
)]
public
long
RatingNone {
get
;
set
; }
[JsonProperty(
"ratingOverweight"
)]
public
long
RatingOverweight {
get
;
set
; }
[JsonProperty(
"ratingScaleMark"
)]
public
double
RatingScaleMark {
get
;
set
; }
[JsonProperty(
"ratingSell"
)]
public
long
RatingSell {
get
;
set
; }
[JsonProperty(
"ratingUnderweight"
)]
public
long
RatingUnderweight {
get
;
set
; }
}
Reply
Answers (
5
)
Capture image crop image using jquery
Migrating an existing DotnetCore WebAPI into Azure Serverless function