Hallo zusammen,
derzeit bastle ich an einem kleinen Tool um Auktionen von eBay zu listen. Sagen wir, ich habe ein Programm, womit ich auf die API von eBay zugreife um ohne mich anzumelden Auktionen einsehen kann. Das Prüfergebnis sieht beispielweise so aus.
{
"searchOptions": {
"q": "Unterhosen",
"size": 1,
"extension": {},
"attr": {},
"pictureRequired": false,
"includeTopAds": false,
"lastSearchPush": false,
"bizBrandingSearch": false,
"userInventorySearch": false
},
"{http://www.ebayclassifiedsgroup.com/schema/ad/v1}ads": {
"name": "{http://www.ebayclassifiedsgroup.com/schema/ad/v1}ads",
"declaredType": "com.ebay.ecg.api.spec.v1.schema.ad.Ads",
"scope": "javax.xml.bind.JAXBElement$GlobalScope",
"value": {
"ad": [
{
"price": {
"currency-iso-code": {
"value": {
"value": "EUR",
"localized-label": "EUR"
}
},
"amount": {
"value": 2
},
"price-type": {
"value": "SPECIFIED_AMOUNT"
}
},
"ad-type": {
"value": "OFFERED"
},
"poster-type": {
"value": "PRIVATE"
},
"title": {
"value": "Unterhosen Pantys 110/116"
},
"description": {
"value": "5 Stück von Topolino<br /><br />Standort Rispelerhelmt"
},
"imprint": {},
"ad-address": {
"street": {
"value": ""
},
"state": {
"value": "0"
},
"zip-code": {
"value": "0"
},
"longitude": {
"value": "0"
},
"latitude": {
"value": "0"
},
"radius": {
"value": "7.7"
}
},
"ad-status": {
"value": "ACTIVE"
},
"store-id": {},
"store-title": {},
"store-url-extension": {},
"ad-source-id": {},
"phone": {},
"start-date-time": {
"value": "2022-04-17T17:34:39.000+0200"
},
"last-user-edit-date": {},
"features-active": {
"feature-active": []
},
"category": {
"id-name": {
"value": "Baby_Kinderkleidung"
},
"localized-name": {
"value": "Baby- & Kinderkleidung"
},
"link": [],
"category": [],
"id": "22"
},
"locations": {
"location": [
{
"id-name": {
"value": "26409"
},
"localized-name": {
"value": "0 0"
},
"radius": {
"value": "7.7"
},
"regions": {
"region": [
{
"localized-name": {
"value": "0"
}
}
],
"localized-label": "0"
},
"location": [],
"id": "3001"
}
]
},
"buy-now": {
"selected": "false"
},
"attributes": {
"attribute": [
{
"value": [
{
"value": "wasche",
"localized-label": "Wäsche"
}
],
"name": "baby_kinderkleidung.type",
"unit": "",
"search-display": "false",
"fake-sub-category": "true",
"type": "ENUM",
"localized-label": "Art"
},
{
"value": [
{
"value": "ja",
"localized-label": "Versand möglich"
}
],
"name": "baby_kinderkleidung.versand",
"unit": "",
"search-display": "true",
"fake-sub-category": "false",
"localized-tag": "Versand möglich",
"type": "ENUM",
"localized-label": "Versand"
},
{
"value": [
{
"value": "110",
"localized-label": "110"
}
],
"name": "baby_kinderkleidung.groesse",
"unit": "",
"search-display": "true",
"fake-sub-category": "false",
"type": "ENUM",
"localized-label": "Größe"
},
{
"value": [
{
"value": "maedchen",
"localized-label": "Mädchen"
}
],
"name": "baby_kinderkleidung.art",
"unit": "",
"search-display": "true",
"fake-sub-category": "false",
"type": "ENUM",
"localized-label": "Mädchen & Jungen"
}
]
},
"link": [
{
"href": "https://api.ebay-kleinanzeigen.de:443/api/ads/2081222974",
"rel": "self"
},
{
"href": "https://www.ebay-kleinanzeigen.de/s-anzeige/unterhosen-pantys-110-116/2081222974-22-3001",
"rel": "self-public-website"
}
],
"pictures": {
"picture": [
{
"link": [
{
"href": "https://i.ebayimg.com/00/s/MTE1M1gxNDg1/z/kG0AAOSw2oJiXDNX/$_0.JPG",
"rel": "thumbnail"
},
{
"href": "https://i.ebayimg.com/00/s/MTE1M1gxNDg1/z/kG0AAOSw2oJiXDNX/$_2.JPG",
"rel": "teaser"
},
{
"href": "https://i.ebayimg.com/00/s/MTE1M1gxNDg1/z/kG0AAOSw2oJiXDNX/$_1.JPG",
"rel": "large"
},
{
"href": "https://i.ebayimg.com/00/s/MTE1M1gxNDg1/z/kG0AAOSw2oJiXDNX/$_59.JPG",
"rel": "extraLarge"
},
{
"href": "https://i.ebayimg.com/00/s/MTE1M1gxNDg1/z/kG0AAOSw2oJiXDNX/$_57.JPG",
"rel": "XXL"
},
{
"href": "https://i.ebayimg.com/00/s/MTE1M1gxNDg1/z/kG0AAOSw2oJiXDNX/$_{imageId}.JPG",
"rel": "canonicalUrl"
}
]
},
{
"link": [
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/tPsAAOSwD9FiXDNZ/$_0.JPG",
"rel": "thumbnail"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/tPsAAOSwD9FiXDNZ/$_2.JPG",
"rel": "teaser"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/tPsAAOSwD9FiXDNZ/$_1.JPG",
"rel": "large"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/tPsAAOSwD9FiXDNZ/$_59.JPG",
"rel": "extraLarge"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/tPsAAOSwD9FiXDNZ/$_57.JPG",
"rel": "XXL"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/tPsAAOSwD9FiXDNZ/$_{imageId}.JPG",
"rel": "canonicalUrl"
}
]
},
{
"link": [
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/eVAAAOSwM7NiXDNb/$_0.JPG",
"rel": "thumbnail"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/eVAAAOSwM7NiXDNb/$_2.JPG",
"rel": "teaser"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/eVAAAOSwM7NiXDNb/$_1.JPG",
"rel": "large"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/eVAAAOSwM7NiXDNb/$_59.JPG",
"rel": "extraLarge"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/eVAAAOSwM7NiXDNb/$_57.JPG",
"rel": "XXL"
},
{
"href": "https://i.ebayimg.com/00/s/MTYwMFgxMjAw/z/eVAAAOSwM7NiXDNb/$_{imageId}.JPG",
"rel": "canonicalUrl"
}
]
},
{
"link": [
{
"href": "https://i.ebayimg.com/00/s/MTIwMFgxNjAw/z/vvgAAOSwZHRiXDNd/$_0.JPG",
"rel": "thumbnail"
},
{
"href": "https://i.ebayimg.com/00/s/MTIwMFgxNjAw/z/vvgAAOSwZHRiXDNd/$_2.JPG",
"rel": "teaser"
},
{
"href": "https://i.ebayimg.com/00/s/MTIwMFgxNjAw/z/vvgAAOSwZHRiXDNd/$_1.JPG",
"rel": "large"
},
{
"href": "https://i.ebayimg.com/00/s/MTIwMFgxNjAw/z/vvgAAOSwZHRiXDNd/$_59.JPG",
"rel": "extraLarge"
},
{
"href": "https://i.ebayimg.com/00/s/MTIwMFgxNjAw/z/vvgAAOSwZHRiXDNd/$_57.JPG",
"rel": "XXL"
},
{
"href": "https://i.ebayimg.com/00/s/MTIwMFgxNjAw/z/vvgAAOSwZHRiXDNd/$_{imageId}.JPG",
"rel": "canonicalUrl"
}
]
},
{
"link": [
{
"href": "https://i.ebayimg.com/00/s/MTA0M1gxNDEz/z/uWIAAOSwbNdiXDNj/$_0.JPG",
"rel": "thumbnail"
},
{
"href": "https://i.ebayimg.com/00/s/MTA0M1gxNDEz/z/uWIAAOSwbNdiXDNj/$_2.JPG",
"rel": "teaser"
},
{
"href": "https://i.ebayimg.com/00/s/MTA0M1gxNDEz/z/uWIAAOSwbNdiXDNj/$_1.JPG",
"rel": "large"
},
{
"href": "https://i.ebayimg.com/00/s/MTA0M1gxNDEz/z/uWIAAOSwbNdiXDNj/$_59.JPG",
"rel": "extraLarge"
},
{
"href": "https://i.ebayimg.com/00/s/MTA0M1gxNDEz/z/uWIAAOSwbNdiXDNj/$_57.JPG",
"rel": "XXL"
},
{
"href": "https://i.ebayimg.com/00/s/MTA0M1gxNDEz/z/uWIAAOSwbNdiXDNj/$_{imageId}.JPG",
"rel": "canonicalUrl"
}
]
}
]
},
"documents": {
"document": []
},
"displayoptions": {
"reduced-ads-on-vip": {
"value": "false"
},
"hide-ads-on-vip": {
"value": "false"
},
"show-ratings": {
"value": "true"
},
"ad-flagging-enabled": {
"value": "true"
},
"hide-similard-ads-on-vip": {
"value": "false"
},
"category-change-allowed": {
"value": "true"
},
"offer-allowed": {
"value": "true"
},
"secure-payment-possible": {
"value": "false"
},
"ad-description-formatting-enabled": {
"value": "false"
},
"ad-documents-upload-enabled": {
"value": "false"
},
"display-map-on-vip": {
"value": "false"
}
},
"medias": {
"media": []
},
"otherAttributes": {},
"id": "2081222974"
}
],
"paging": {
"numFound": "10360",
"exactNumFound": "true",
"link": [
{
"href": "https://api.ebay-kleinanzeigen.de:443/api/ads.json?q=Unterhosen&pictureRequired=false&page=0&size=1&_ver=1.16",
"rel": "self"
},
{
"href": "https://www.ebay-kleinanzeigen.de/s-unterhosen/k0",
"rel": "self-public-website"
},
{
"href": "https://www.ebay-kleinanzeigen.de/s-unterhosen/k0",
"rel": "self-public-website-canonical"
},
{
"href": "https://api.ebay-kleinanzeigen.de:443/api/ads.json?q=Unterhosen&pictureRequired=false&indexDate=2022-04-17T17%3A34%3A39&page=1&size=1&_ver=1.16",
"rel": "next"
}
]
},
"ads-search-options": {
"q": {
"value": "Unterhosen"
},
"page": {
"value": "0"
},
"size": {
"value": "1"
},
"pictureRequired": {
"value": "false"
},
"indexDate": {
"value": "2022-04-17T17:34:39.000+0200"
}
},
"ads-search-histograms": {},
"ads-search-result-metadata": {
"title": {
"value": "Unterhosen eBay Kleinanzeigen"
},
"description": {
"value": "eBay Kleinanzeigen: Unterhosen, Kleinanzeigen - Jetzt finden oder inserieren! eBay Kleinanzeigen - Kostenlos. Einfach. Lokal."
}
}
},
"nil": false,
"globalScope": true,
"typeSubstituted": false
}
}
Alles anzeigen
Ich gehe also hin und versuche das nun zu deserialisieren.
strResponse = new HttpRequests().GetResponse(ref httpRequest, useCookie: false);
ObservableCollection<Ad> dataList = JsonConvert.DeserializeObject<ObservableCollection<Ad>>(strResponse);
foreach (var p in dataList)
{
richTextBox1.AppendText(p.res_data.title + "\n");
}
Als Fehler bekomme ich immer
ZitatNewtonsoft.Json.JsonSerializationException: "Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.ObjectModel.ObservableCollection`1[S_Checker.Ad]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'searchOptions', line 1, position 17."
Google zeigt mir nun zwar Lösungen, allerdings kann ich damit nicht arbeiten, da keine der Lösungen funktioniert. Hat hier eventuell Jemand ne Idee?
Möchte das ganze so als DataTable oder so in einer Liste haben