I have a question about getting Data from a SQL Database via ASP.NET and then passing the data over to Objective-C. Currently I am just using an SQL select statement to get data from the database via ASP.NET and ASP.NET returns the data like so:
<ArrayOfKeyValueOfstringPunchListCellModel84zsBx89 xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<KeyValueOfstringPunchListCellModel84zsBx89>
<Key>ORC0023</Key>
<Value xmlns:d3p1="http://schemas.datacontract.org/2004/07/LHS.Models">
</Value>
</KeyValueOfstringPunchListCellModel84zsBx89>
</ArrayOfKeyValueOfstringPunchListCellModel84zsBx89>
And then in Objective-C I am putting the data in a NSDictionary like so:
NSDictionary *punchList = [[NSDictionary alloc]initWithDictionary:[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&myError]];
Everything is working as expected here.
What I am doing now is creating a stored procedure that returns XML and have ASP.NET return the XML (everything here is completed and working as expected) The XML came out like so:
<KeyValueOfstringPunchListCellModel84zsBx89>
<Key>ORC0023</Key>
<Value>
</Value>
</KeyValueOfstringPunchListCellModel84zsBx89>
</ArrayOfKeyValueOfstringPunchListCellModel84zsBx89>
Now for you Objective-C fans, you know you can’t have XML in NSDictionary unless you use a third party item/library.
Now my question is do I have redo my stored procedure to return JSON or this there another way to go about this?
My end goal is make the process as fast as possible and the SQL query is huge and returns alot of rows.
You should
1) redo your stored proc and return the raw data.
2) Have asp.net handle the data formatting, since some clients might want JSON while others would prefer xml. so if you're going the JSON route, you can return JSON result from the MVC controller i.e
public JsonResult GetData()
{
var temp = new {
name = "hello world"
};
return this.Json(temp)
}
or create a web service using web api.
since you have a large result set, you should try using JSON which is less verbose than xml and thus will eat up less resources
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With