Newtonsoft JSON反序列化

时间:2015-12-04 08:56:05

标签: json web asp.net-web-api2 json-deserialization

我有一个webapi2函数,在完成时会返回一个json响应。 但是当我尝试在我的网络应用程序中反序列化它时,使用newtonsoft JSON,我收到以下错误:

我尝试通过在线json解析器运行返回json而没有任何错误,所以有点无能为力......

收到错误:

  

未处理的承诺拒绝SyntaxError:意外的令牌u at   Object.parse(native)

任何线索??

收到的json如下:

[{
"Fragtbrev": {
    "$id": "1",
    "Id": 95259,
    "Fragtbrevsnummer": "FD010462",
    "ClientKey": "5fe8b831-3614-4e35-99ff-b41475d3f6e5",
    "AfsenderKundenummer": "40385654",
    "Aftalenr": "40385654",
    "Afhentningsdato": "2015-12-04T10:00:00",
    "Fragtbrevsdato": "20151204",
    "Efterkrav": null,
    "volumepakke": null,
    "DirekteLevering": null,
    "EfterkravKontant": null,
    "EfterkravsBelob": null,
    "EfterkravsbelobValuta": null,
    "Efterkravsgebyr": null,
    "EfterkravsgebyrValuta": null,
    "Forsikringstype": "0",
    "Forsikringsvaerdi": null,
    "ForsikringsvaerdiValuta": null,
    "Langgods": false,
    "Leveringsbemaerkning": null,
    "LeveringsbemaerkningPaaLabel": null,
    "Leveringsinformation": null,
    "Afsenderreference": null,
    "Reference": null,
    "Reference2": null,
    "Reference3": null,
    "Reference4": null,
    "ArtTotal": null,
    "Frankatur": "F",
    "Fragtcentral": "WA",
    "Rutefm1": "190",
    "Rutefm2": "201",
    "Alternativtpostnr": null,
    "Afsendernavn": "Danish Freight Guys",
    "Afsendernavn2": null,
    "Afsenderadresse": "Solvejen 24",
    "Afsenderadresse2": null,
    "Afsenderby": "Egå",
    "Afsenderpostnr": "8250",
    "Afsenderkontaktperson": null,
    "AfsenderTlf": "40385654",
    "AfsenderEmail": null,
    "Afsenderland": "DK",
    "Modtagernavn": "DSR Scandinavia",
    "Modtagernavn2": "",
    "Modtageradresse": "Frederiksborgvej 521",
    "Modtageradresse2": "",
    "Modtagerby": "Roskilde",
    "Modtagerpostnr": "4000",
    "Modtagertelefon": "46732626",
    "Modtagerland": "DK",
    "ModtagerEmail": "dsr@genfinder.com",
    "ModtagerKontaktperson": "",
    "Modtagerkundenummer": null,
    "AntalkgTotal": 1.0,
    "Antalm3Total": 1.0,
    "AntalLdmTotal": 1.0,
    "AntalPakkerTotal": null,
    "Fgods": false,
    "Helpaller": null,
    "Halvpaller": null,
    "Kvartpaller": null,
    "Byttepalle": false,
    "Pallepladser": null,
    "Returgods": null,
    "Tidslevering": false,
    "LevTidligstDatoTid": null,
    "LevSenestDatoTid": null,
    "Colliscanning": "",
    "Advisering": null,
    "AfhenterKrakID": null,
    "ModtagerKrakID": "",
    "AfhSenestDatoTid": null,
    "AfhTidligstDatoTid": null,
    "TimeStamp": "AAAAAAAw8uE=",
    "KundeId": null,
    "Bestillernavn": "Danish Freight Guys",
    "Bestilleradresse": "Solvejen 24",
    "Bestillerpostnr": "8250",
    "Bestillerby": "Egå",
    "Bestillertelefon": "40385654",
    "BestillerEmail": "soren.r.muller@fragt.dk",
    "BestillerKontaktperson": "Banjomus",
    "Bestillerkundenummer": "40385654",
    "Bestillerland": "DK",
    "Valid": true,
    "Booket": false,
    "Afleveret": false,
    "FragtbrevUdskrevet": false,
    "LabelsUdskrevet": true,
    "FragtbrevslisteUdskrevet": false,
    "Afsluttet": false,
    "Slettet": false,
    "Annulleret": false,
    "SenesteStregkode": null,
    "FragtbrevStatusId": 2,
    "FragtStatusId": null,
    "Oprettet": "2015-12-04T09:34:31.013",
    "ForsendelsestypeId": 4,
    "Locked": false,
    "Reference5": null,
    "FragtbrevsType": "Afhentning",
    "PrintFlagsForSorting": 2,
    "Servicekoder": "",
    "Version": 1,
    "MedtagPaaLabel": false,
    "Modtagergruppe": null,
    "WSComLastSent": "2015-12-04T09:35:02.6808917+01:00",
    "WSComAckStatus": "",
    "WBSBookingSentTimestamp": "2015-12-04T09:35:02.6348884+01:00",
    "WBSBookingAckStatus": "Afventer svar",
    "WBSBookingStatus": null,
    "BookingNr": null,
    "Tur": null,
    "SkabelonNavn": null,
    "AfhentningsAdresseId": 1063,
    "ReturBemaerkning": null,
    "AlternativAfsender": false,
    "AfsenderKartotekNummer": null,
    "ModtagerKartotekNummer": "46732626",
    "AutomatiskBookingTid": "2015-12-04T13:00:00",
    "AfhentningsBemaerkning": null,
    "ImageCount": 0,
    "Klartid": "2015-12-04T10:00:00",
    "Lukketid": null,
    "OverFoertTilEDI": false,
    "PrintLabels": true,
    "PrintFragtbrev": false,
    "SenestSletningOgLaasningstid": "2015-12-04T10:00:00",
    "OriginalDOTTime": null,
    "ColliKode": [{
        "$id": "2",
        "ID": 73215,
        "FId": 95259,
        "ColliNr": 1,
        "ColliKode1": "90403856549100001401FD010462",
        "Udskrevet": false,
        "GId": 20435,
        "Fragtbrev": {
            "$ref": "1"
        },
        "GodsLinje": {
            "$id": "3",
            "dID": 20435,
            "fID": 95259,
            "Antal": 2,
            "Art": "PL1",
            "Indhold": "dsa",
            "Vaegt": 1.0,
            "Rumfang": 1.0,
            "Ladmeter": 1.0,
            "Laengde": null,
            "Bredde": null,
            "Hoejde": null,
            "ColliKode": [{
                "$ref": "2"
            }, {
                "$id": "4",
                "ID": 73216,
                "FId": 95259,
                "ColliNr": 2,
                "ColliKode1": "90403856549100002401FD010462",
                "Udskrevet": false,
                "GId": 20435,
                "Fragtbrev": {
                    "$ref": "1"
                },
                "GodsLinje": {
                    "$ref": "3"
                },
                "ChangeTracker": {
                    "$id": "5",
                    "State": 2,
                    "ObjectsRemovedFromCollectionProperties": {},
                    "OriginalValues": {},
                    "ExtendedProperties": {},
                    "ObjectsAddedToCollectionProperties": {}
                }
            }],
            "Fragtbrev": {
                "$ref": "1"
            },
            "ChangeTracker": {
                "$id": "6",
                "State": 1,
                "ObjectsRemovedFromCollectionProperties": {},
                "OriginalValues": {},
                "ExtendedProperties": {},
                "ObjectsAddedToCollectionProperties": {}
            }
        },
        "ChangeTracker": {
            "$id": "7",
            "State": 2,
            "ObjectsRemovedFromCollectionProperties": {},
            "OriginalValues": {},
            "ExtendedProperties": {},
            "ObjectsAddedToCollectionProperties": {}
        }
    }, {
        "$ref": "4"
    }],
    "Forsendelsestype": null,
    "FragtbrevStatus": null,
    "FragtStatus": null,
    "Kunde": null,
    "GodsLinje": [{
        "$ref": "3"
    }],
    "Stregkode": [],
    "ChangeTracker": {
        "$id": "8",
        "State": 1,
        "ObjectsRemovedFromCollectionProperties": {},
        "OriginalValues": {},
        "ExtendedProperties": {},
        "ObjectsAddedToCollectionProperties": {}
    }
},
"WarnBookedTooLate": false

}]

1 个答案:

答案 0 :(得分:0)

解决.. 我正在解析response.content,这是一个排序的数组.. 将其更改为response.response,这是字符串版本..