So I wanted to create an inventory system and I have coded and done a few things. However now it is showing an error in the item database code. The error is:
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary2[System.Int32,System.Collections.Generic.IDictionary2[System.Int32,System.Int32[]]].get_Item (Int32 key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
LitJson.JsonReader.Read ()
Rethrow as JsonException: Invalid token '123' in input string
LitJson.JsonReader.Read ()
LitJson.JsonMapper.ReadValue (LitJson.WrapperFactory factory, LitJson.JsonReader reader)
LitJson.JsonMapper.ReadValue (LitJson.WrapperFactory factory, LitJson.JsonReader reader)
LitJson.JsonMapper.ReadValue (LitJson.WrapperFactory factory, LitJson.JsonReader reader)
LitJson.JsonMapper.ToWrapper (LitJson.WrapperFactory factory, System.String json)
LitJson.JsonMapper.ToObject (System.String json)
ItemDatabase.Start () (at Assets/All/Scripts/ItemDatabase.cs:13)
and it became very annoying since I couldn't figure out how to fix it. My 2 files currently are:
using System.Collections;
using System.Collections.Generic;
using LitJson;
using UnityEngine;
using System.IO;
public class ItemDatabase : MonoBehaviour {
private List<Item> database = new List<Item>();
private JsonData itemData;
void Start()
{
itemData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/StreamingAssets/Items.json"));
ConstructItemDatabase();
Debug.Log(database[1].Slug);
}
void ConstructItemDatabase()
{
for (int i = 0; i < itemData.Count; i++)
{
database.Add(new Item((int)itemData[i]["id"], itemData[i]["title"].ToString(), (int)itemData[i]["value"],
(int)itemData[i]["stats"]["power"], (int)itemData[i]["stats"]["defence"], (int)itemData[i]["stats"]["vitality"], itemData[i]["description"].ToString(),
(bool)itemData[i]["stackable"], (int)itemData[i]["rarity"],
itemData[i]["slug"].ToString()));
}
}
}
public class Item
{
public int ID { get; set; }
public string Title { get; set; }
public int Value { get; set; }
public int Power { get; set; }
public int Defence { get; set; }
public int Vitality { get; set; }
public string Description { get; set; }
public bool Stackable { get; set; }
public int Rarity { get; set; }
public string Slug { get; set; }
public Item(int id, string title, int value, int power, int defence, int vitality, string description, bool stackable, int rarity, string slug)
{
this.ID = id;
this.Title = title;
this.Value = value;
this.Power = power;
this.Defence = defence;
this.Vitality = vitality;
this.Description = description;
this.Stackable = stackable;
this.Rarity = rarity;
this.Slug = slug;
}
public Item()
{
this.ID = -1;
}
}
Here the top one is my ItemDatabase.cs file. It has a few spaces and brackets are wrong I know but it is actually all fine. I will post a screenshot with the whole code. Since I am new to using this Code Sample tool.
And here is my Items.json file.
[
{
"id": 0,
"title": "Wood Pickaxe",
"value": 6,
"stats" {
"power": 1,
"defence": 0,
"vitality": 0
},
"description": "A basic wood pickaxe.",
"stackable": false,
"rarity": 1,
"slug": "wood_pickaxe"
},
{
"id": 1,
"title": "Wood Pickaxe Head",
"value": 543,
"stats" {
"power": 1,
"defence": 0,
"vitality": 0
},
"description": "A piece of a broken wood pickaxe.",
"stackable": false,
"rarity": 1,
"slug": "wood_pickaxe_head"
}
]
I will also post a screenshot of this code. Please help. This is very frustrating and the other posts about this won't help. Items.json screenshot ItemDatabase.cs screenshot
You have an error in your json. The error itself is a little misleading. Every time I've seen it, there was a json syntax issue involved.
[
{
"id": 0,
"title": "Wood Pickaxe",
"value": 6,
"stats": { // <-- problem was here. missing colon
"power": 1,
"defence": 0,
"vitality": 0
},
"description": "A basic wood pickaxe.",
"stackable": false,
"rarity": 1,
"slug": "wood_pickaxe"
},
{
"id": 1,
"title": "Wood Pickaxe Head",
"value": 543,
"stats": { // <-- problem was here. missing colon
"power": 1,
"defence": 0,
"vitality": 0
},
"description": "A piece of a broken wood pickaxe.",
"stackable": false,
"rarity": 1,
"slug": "wood_pickaxe_head"
}
]
Related
I am getting the following response from an API
"results": {
"wan1": {
"id": "wan1",
"name": "wan1",
"alias": "",
"mac": "00:00:00:00:00:00",
"ip": "102.165.223.199",
"mask": 24,
"link": true,
"speed": 1000.0,
"duplex": 1,
"tx_packets": 501850173,
"rx_packets": 307154377,
"tx_bytes": 442319826490,
"rx_bytes": 234140958061,
"tx_errors": 0,
"rx_errors": 0
},
"dmz": {
"id": "dmz",
"name": "dmz",
"alias": "",
"mac": "00:00:00:00:00:00",
"ip": "10.10.10.1",
"mask": 24,
"link": false,
"speed": 0.0,
"duplex": 0,
"tx_packets": 0,
"rx_packets": 0,
"tx_bytes": 0,
"rx_bytes": 0,
"tx_errors": 0,
"rx_errors": 0
},
"internal1": {
"id": "internal1",
"name": "internal1",
"alias": "",
"mac": "00:00:00:00:00:00",
"ip": "0.0.0.0",
"mask": 0,
"link": false,
"speed": 0.0,
"duplex": 0,
"tx_packets": 0,
"rx_packets": 0,
"tx_bytes": 0,
"rx_bytes": 0,
"tx_errors": 0,
"rx_errors": 0
}
},
"vdom": "root",
}
I have tried a few approaches to representing this JSON in c# objects
{
public Dictionary<string, List<Result>> Result { get; set; }
}
public class Result
{
public string name { get; set; }
public string ip { get; set; }
public int tx_bytes { get; set; }
public int rx_bytes { get; set; }
}
And here is the method I am using to deserialize the JSON:
var result = await client.Request()
.AppendPathSegment("api/v2/monitor/system/interface")
.SetQueryParam("access_token", token)
.GetJsonAsync<InterfaceResponse>(cancellationToken: cancellationToken);
It should be simple, but for some reason, I can't figure out the correct object representation, but when I debug I am getting null
Thanks for the help.
I can see 2 issues:
It's "results" not "result".
"results" looks like Dictionary<string, Result> not Dictionary<string, List<Result>>.
Additionally, if you're using System.Text.Json then casing may matter depending on your settings.
try this
var jsonParsed = JObject.Parse(json);
Dictionary<string,Result> results = jsonParsed["results"]
.ToObject<Dictionary<string,Result>>();
string vdom = (string)jsonParsed["vdom"];
public class Result
{
public string name { get; set; }
public string ip { get; set; }
public long tx_bytes { get; set; }
public long rx_bytes { get; set; }
//another properties
}
You need to fix the classes:
public class InterfaceResponse
{
// 1. rename or use attributes
// 2. fix type from Dictionary<string, List<Result>>
public Dictionary<string, Result> results { get; set; }
}
public class Result
{
public string name { get; set; }
public string ip { get; set; }
public long tx_bytes { get; set; } // use long, some of the values are too big to fit int
public long rx_bytes { get; set; } // use long, some of the values are too big to fit int
}
I'm having problems reading Children of the root element and understanding where I'm going wrong in the JSON below:
{
"001": {
"peers": [
{
"id": 0,
"server": "1.1.1.1:80",
"name": "1.1.1.1:80",
"backup": false,
"weight": 1,
"state": "up",
"active": 0,
"requests": 0,
"responses": {
"1xx": 0,
"2xx": 0,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"total": 0
},
"sent": 0,
"received": 0,
"fails": 0,
"unavail": 0,
"health_checks": {
"checks": 0,
"fails": 0,
"unhealthy": 0
},
"downtime": 0
},
{
"id": 1,
"server": "127.0.0.1:8888",
"name": "127.0.0.1:8888",
"backup": false,
"weight": 1,
"state": "down",
"active": 0,
"requests": 0,
"responses": {
"1xx": 0,
"2xx": 0,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"total": 0
},
"sent": 0,
"received": 0,
"fails": 0,
"unavail": 0,
"health_checks": {
"checks": 0,
"fails": 0,
"unhealthy": 0
},
"downtime": 0
}
],
"keepalive": 0,
"zombies": 0,
"zone": "001"
},
"002": {
"peers": [
{
"id": 0,
"server": "1.1.1.2:80",
"name": "1.1.1.2:80",
"backup": false,
"weight": 1,
"state": "up",
"active": 0,
"requests": 0,
"responses": {
"1xx": 0,
"2xx": 0,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"total": 0
},
"sent": 0,
"received": 0,
"fails": 0,
"unavail": 0,
"health_checks": {
"checks": 0,
"fails": 0,
"unhealthy": 0
},
"downtime": 0
},
{
"id": 1,
"server": "127.0.0.1:8888",
"name": "127.0.0.1:8888",
"backup": false,
"weight": 1,
"state": "down",
"active": 0,
"requests": 0,
"responses": {
"1xx": 0,
"2xx": 0,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"total": 0
},
"sent": 0,
"received": 0,
"fails": 0,
"unavail": 0,
"health_checks": {
"checks": 0,
"fails": 0,
"unhealthy": 0
},
"downtime": 0
}
],
"keepalive": 0,
"zombies": 0,
"zone": "002"
}
}
I know I can pass the JSON into a JObject and find the server value below by naming the 001 JSON object:
JObject obj = JObject.Parse(jsonResponse);
var h = obj.Value<JObject>("001").Value<JArray>("peers")[0].SelectToken("server").ToString();
However I'd like to read the children of the root element (which I think are objects 001 and 002) regardless of their names, foreach through them to find values for the keys "zone" and "keepalive". I thought I could do this:
List<JToken> toks = obj.Root.Children().ToList<JToken>();
string output = "";
foreach (JToken token in toks)
{
JProperty prop = (JProperty)token;
output += prop.Value<string>("zone"); // returns nothing
string bla = token.ToString(); //returns 001 and all it's child objects
}
But the output string is blank. I can see that if I try token.ToString() the JToken object has stuff in it, but I can't seem to read it.
If I use Visual studio to create an object for Deserialization I get this for the root object which confuses me further:
public class Rootobject
{
public 001 001 { get; set; }
public 002 002 { get; set; }
}
What am I doing wrong? Any help would be greatly appreciated.
Jon
If you're trying to parse this JSON using JTokens, you need to understand the different kinds of possible tokens and the relationships between them. You would probably benefit from reading this answer.
At the root you have an object; this object has two properties called "001" and "002". Those properties' respective values are objects again, containing their own properties ("peers", "keepalive", "zombies" and "zone"). And so on.
If you ultimately want to loop through the root properties without knowing their names and then dump out the values of "zone" and "keepalive" properties of the child objects, you can do it like this:
var obj = JObject.Parse(json);
foreach (JProperty prop in obj.Properties())
{
var item = (JObject)prop.Value;
var zone = (string)item["zone"];
var keepalive = (int)item["keepalive"];
Console.WriteLine($"Zone: {zone} keepalive: {keepalive}");
}
Fiddle: https://dotnetfiddle.net/tNut9v
If JTokens make your head spin, then you might be better off declaring classes for the JSON. The only wrinkle is the dynamic property names in the root ("001", "002"). But you can handle that by deserializing to a Dictionary<string, T> where T is an Item class as shown below. Define the classes like this:
public class Item
{
public List<Peer> peers { get; set; }
public int keepalive { get; set; }
public int zombies { get; set; }
public string zone { get; set; }
}
public class Peer
{
public int id { get; set; }
public string server { get; set; }
public string name { get; set; }
public bool backup { get; set; }
public int weight { get; set; }
public string state { get; set; }
public int active { get; set; }
public int requests { get; set; }
public Responses responses { get; set; }
public int sent { get; set; }
public int received { get; set; }
public int fails { get; set; }
public int unavail { get; set; }
public HealthChecks health_checks { get; set; }
public int downtime { get; set; }
}
public class Responses
{
[JsonProperty("1xx")]
public int code_1xx { get; set; }
[JsonProperty("2xx")]
public int code_2xx { get; set; }
[JsonProperty("3xx")]
public int code_3xx { get; set; }
[JsonProperty("4xx")]
public int code_4xx { get; set; }
[JsonProperty("5xx")]
public int code_5xx { get; set; }
public int total { get; set; }
}
public class HealthChecks
{
public int checks { get; set; }
public int fails { get; set; }
public int unhealthy { get; set; }
}
Then you can deserialize and dump out the data you want like this:
var dict = JsonConvert.DeserializeObject<Dictionary<string, Item>>(json);
foreach (var kvp in dict)
{
Item item = kvp.Value;
Console.WriteLine($"Zone: {item.zone} keepalive: {item.keepalive}");
}
Fiddle: https://dotnetfiddle.net/3rRmxJ
I have the class below:
public class Product
{
[JsonProperty("image")]
public string ImageURL { get; set; }
[JsonProperty("superDepartment")]
public string SuperDepartment { get; set; }
[JsonProperty("tpnb")]
public long TPNB { get; set; }
[JsonProperty("ContentsMeasureType")]
public string ContentsMeasureType { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("UnitOfSale")]
public int UnitOfSale { get; set; }
[JsonProperty("description")]
public IEnumerator<string> LstDescription { get; set; }
public string Description { get; set; }
[JsonProperty("AverageSellingUnitWeight")]
public decimal AverageSellingUnitWeight { get; set; }
[JsonProperty("UnitQuantity")]
public string UnitQuantity { get; set; }
[JsonProperty("id")]
public long ID { get; set; }
[JsonProperty("ContentsQuantity")]
public int ContentsQuantity { get; set; }
[JsonProperty("department")]
public string Department { get; set; }
[JsonProperty("price")]
public decimal Price { get; set; }
[JsonProperty("unitprice")]
public decimal UnitPrice { get; set; }
}
I have the method on the productController:
public async Task<ActionResult> MakeRequest(string q)// worked
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "56ac439a92694577a2779f3d0ee0cd85");
var uri = string.Format("https://dev.tescolabs.com/grocery/products/?query={0}&offset={1}&limit={2}", q, 0, 10);
var response = await client.GetAsync(uri);
string body = await response.Content.ReadAsStringAsync();
Product myoutput = JsonConvert.DeserializeObject<Product>(body);
}
return View(body);
}
and I have the model below:
For some reason when I call the method MakeRequest it just shows the information as a string and an error saying Server Error as per picture below we can see the information from the api but it is showing as a string.
error message
The information from the api it should be showing on the table below:
table
How to show the data on the table? Or better how to convert the json array to a net object?
I know there is something missing in the part below of my method:
Product myoutput = JsonConvert.DeserializeObject<Product>(body);
You're passing json string to your View instead of your deserialized Product.
I assume your View expects model of type Product.
The return statement of MakeRequest action should be return View(myOutput);
I'll tell you in a simple way.
Your json model
-uk
--ghs
---products
----results
{
"uk" : {
"ghs" : {
"products": {
"input_query": "babana",
"output_query": "banana",
"filters": {},
"queryPhase": "post_primary",
"totals": {
"all": 109,
"new": 1,
"offer": 47
},
"config": "default",
"results": [
{
"image": "http://img.tesco.com/Groceries/pi/000/0261480000000/IDShot_90x90.jpg",
"superDepartment": "Fresh Food",
"tpnb": 50502269,
"ContentsMeasureType": "KG",
"name": "Tesco Bananas Loose",
"UnitOfSale": 3,
"description": [ "To help ensure the banana farms we source from are best in class we, and our", "suppliers, now work closely with the Rainforest Alliance, an international", "non profit organisation that works to conserve biodiversity and ensure", "sustainable livelihoods worldwide.", "The Rainforest Alliance Certified™ seal on our bananas a green frog nestled", "in a circle – helps us to tell the story of how they are sustainably sourced,", "and assure customers we are sourcing from responsibly managed farms." ],
"AverageSellingUnitWeight": 2.402,
"UnitQuantity": "KG",
"id": 275280804,
"ContentsQuantity": 1,
"department": "Fresh Fruit",
"price": 0.76,
"unitprice": 0.76
},
{
"image": "http://img.tesco.com/Groceries/pi/875/0000010001875/IDShot_90x90.jpg",
"superDepartment": "Fresh Food",
"tpnb": 65728590,
"ContentsMeasureType": "SNGL",
"name": "Tesco Ripe Bananas 5 Pack",
"UnitOfSale": 1,
"AverageSellingUnitWeight": 0.862,
"UnitQuantity": "EACH",
"id": 266419328,
"ContentsQuantity": 5,
"department": "Fresh Fruit",
"price": 0.9,
"unitprice": 0.18
},
{
"image": "http://img.tesco.com/Groceries/pi/416/0000003251416/IDShot_90x90.jpg",
"superDepartment": "Fresh Food",
"tpnb": 77427870,
"ContentsMeasureType": "SNGL",
"name": "Tesco Small Bananas 6 Pack",
"UnitOfSale": 1,
"description": [ "Small Bananas", "Tesco Small Bananas" ],
"AverageSellingUnitWeight": 0.965,
"UnitQuantity": "EACH",
"id": 285157326,
"ContentsQuantity": 6,
"department": "Fresh Fruit",
"price": 0.9,
"unitprice": 0.15
}
],
"suggestions": []
}
}
}
}
If you look at the above json result, you need a more comprehensive model.
For this you can enter the json result into a model here. look here
or keep the result object from its current state with dynamic.
string body = response.Content.ReadAsStringAsync().Result;
dynamic content = JObject.Parse(body);
var products = content.uk.ghs.products.results;
Hello i've got this error Message
"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'ClassLibraryMifosX.ViewModels.Rootobject2' 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 JS
my deserialize code :
Rootobject Rsc = JsonConvert.DeserializeObject<Rootobject>(json);
my class with json object description:
public class Rootobject
{
public List<Class1> Property1 { get; set; }
}
public class Class1
{
public int entityId { get; set; }
public string entityAccountNo { get; set; }
public string entityExternalId { get; set; }
public string entityName { get; set; }
public string entityType { get; set; }
public int parentId { get; set; }
public string parentName { get; set; }
public string entityMobileNo { get; set; }
public Entitystatus entityStatus { get; set; }
}
public class Entitystatus
{
public int id { get; set; }
public string code { get; set; }
public string value { get; set; }
}
my json :
[
{
"entityId": 1,
"entityAccountNo": "000000001",
"entityExternalId": "100001-241563",
"entityName": "Smith W R",
"entityType": "CLIENT",
"parentId": 1,
"parentName": "Head Office",
"entityMobileNo": "254728000000",
"entityStatus": {
"id": 300,
"code": "clientStatusType.active",
"value": "Active"
}
},
{
"entityId": 310,
"entityAccountNo": "000000310",
"entityName": "John Smith",
"entityType": "CLIENT",
"parentId": 14,
"parentName": "TestOffice1",
"entityStatus": {
"id": 300,
"code": "clientStatusType.active",
"value": "Active"
}
},
{
"entityId": 422,
"entityAccountNo": "000000422",
"entityExternalId": "smith1",
"entityName": "Smith Jones",
"entityType": "CLIENT",
"parentId": 11,
"parentName": "Barquisimeto",
"entityMobileNo": "88989898",
"entityStatus": {
"id": 300,
"code": "clientStatusType.active",
"value": "Active"
}
},
{
"entityId": 774,
"entityAccountNo": "000000774",
"entityName": "John AAA Smith",
"entityType": "CLIENT",
"parentId": 1,
"parentName": "Head Office",
"entityStatus": {
"id": 300,
"code": "clientStatusType.active",
"value": "Active"
}
},
{
"entityId": 1789,
"entityAccountNo": "Head Office000001789",
"entityExternalId": "547222",
"entityName": "Kaitlin Smith",
"entityType": "CLIENT",
"parentId": 1,
"parentName": "Head Office",
"entityStatus": {
"id": 300,
"code": "clientStatusType.active",
"value": "Active"
}
}
]
what i have been done wrongly ? Thanks
There is no root object into your Json data so just deserialize it as a collection of Class1 like below:
var collection = JsonConvert.DeserializeObject<List<Class1>>(json);
Don't forget that VS can create for you a class that can be used to deserailize your Json data. You don't need to write yourself the definition of Class1. Just go to menu => Edit > Paste Special > Paste JSON as classes
The first and last character of your JSON is a square bracket [ ] rather than a curly bracket { }. This means that it is an array, not an object. In order to parse it, you need to deserialize it into an array of Class1 objects:
Class1[] Rsc = JsonConvert.DeserializeObject<Class1[]>(json);
If you wanted to use a Rootobject object instead, you could then use it like so:
Rootobject root = new RootObject();
root.Property1 = new List<Class1>(Rsc);
It gives me error when deserializing this JSON File
{
"checkOut": "10:30",
"stars": 4,
"locationId": 953,
"propertyType": 6,
"checkIn": "15:00",
"trustyou": {
"languageSplit": [
{
"tripTypeSplit": [
{
"type": "family",
"percentage": 85
},
{
"type": "couple",
"percentage": 15
}
],
"name": "de",
"percentage": 100
}
],
"location": [
],
"reviewsCount": 83,
"popularity": 0,
"tripTypeSplit": [
{
"type": "family",
"percentage": 86
},
{
"type": "couple",
"percentage": 14
}
],
"sentimentScoreList": [
{
"categoryId": "14",
"ratio": "Good",
"shortText": "Great location",
"name": "Location",
"subcategories": [
],
"highlights": [
{
"text": "Beautiful location",
"confidence": 100
}
],
"reviewCount": 14,
"score": 100
},
{
"categoryId": "111",
"ratio": "Good",
"shortText": "Rather comfortable",
"name": "Comfort",
"subcategories": [
],
"highlights": [
],
"reviewCount": 5,
"score": 100
},
I have the following classes for this JSON
public class Root
{
[JsonProperty("checkIn")]
public string CheckIn { get; set; }
[JsonProperty("distance")]
public double Distance { get; set; }
[JsonProperty("hidden")]
public bool Hidden { get; set; }
[JsonProperty("trustyou")]
public Trustyou Trustyou { get; set; }
[JsonProperty("amenitiesV2")]
public AmenitiesV2 AmenitiesV2 { get; set; }
[JsonProperty("hasAirbnb")]
public bool HasAirbnb { get; set; }
[JsonProperty("checkOut")]
public string CheckOut { get; set; }
[JsonProperty("popularity")]
public int Popularity { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("cntRooms")]
public int CntRooms { get; set; }
What seems to be the problem? i'm deserializing this using
string resp2 = await client.GetStringAsync("");
var hotelDetails = JsonConvert.DeserializeObject<IDictionary<string, HotelsDescriptionAPI.Root>>(resp2, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
foreach (var hoteldesc in hotelDetails)
{
MessageBox.Show(hoteldesc.Value.Id);
}
and the exact error is
"Error converting value 24545 to type and Error converting value "10:30" to type 'HotelsDescriptionAPI.Root'. Path 'checkOut', line 1, position 19."
Im trying to get the value of "Id", What could be the problem with my code?
Your deserialization code should be:
var hotelDetails = JsonConvert.DeserializeObject<HotelsDescriptionAPI.Root>(resp2,
new JsonSerializerSettings {
NullValueHandling = NullValueHandling.Ignore
});
You're trying to deserialize it into a dictionary of string,Root, when the object itself is simply Root.
It does not seem to apply to your scenario, but note that when you do have JSON that is an array (root level children are array items, not properties), you may have to change the root object to subclass a compatible type.
For example:
public class RootObject : List<ChildObject>
{
}
public class ChildObject
{
public string Property1 { get; set; }
public string Property2 { get; set; }
}
For people that this does not help, and that are not using Entity Framework and or writing the domain classes by hand - make sure all your class properties match what is coming out of your data source in the same exact field order.