Metro Style App: JSON Object Deserialization Error, REST Services - json.net

Element ':item' contains data from a type that maps to the name
"http://schemas.microsoft.com/search/local/ws/rest/v1:Route.' The
deserializer has no knowledge of any type that maps to this name.
Consider using a DataContractResolver or add the type corresponding to
'Route' to the list of known types - for example, by using
KnownTypeAttribute attribute or by adding it to the list of known
types passed to DataContractSerializer.
After adding [DataContract(Namespace = "http://schemas.microsoft.com/search/local/ws/rest/v1", Name = "Location")] ro Resource class, I got this exception:
Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''
Likn: http://dev.virtualearth.net/REST/V1/Routes?wp.0=37.779160067439079,-122.42004945874214&wp.1=32.715685218572617,-117.16172486543655&key=BingMapsKey
[KnownType(typeof(double[]))]
[DataContract]
public class ActualEnd
{
[DataMember(Name = "type")]
public string type { get; set; }
[DataMember(Name = "coordinates")]
public List<double> coordinates { get; set; }
}
[KnownType(typeof(double[]))]
[DataContract]
public class ActualStart
{
[DataMember(Name = "type")]
public string type { get; set; }
[DataMember(Name = "coordinates")]
public List<double> coordinates { get; set; }
}
[KnownType(typeof(int[]))]
[KnownType(typeof(string[]))]
[DataContract]
public class Detail
{
[DataMember(Name = "compassDegrees")]
public int compassDegrees { get; set; }
[DataMember(Name = "endPathIndices")]
public List<int> endPathIndices { get; set; }
[DataMember(Name = "maneuverType")]
public string maneuverType { get; set; }
[DataMember(Name = "mode")]
public string mode { get; set; }
[DataMember(Name = "roadType")]
public string roadType { get; set; }
[DataMember(Name = "startPathIndices")]
public List<int> startPathIndices { get; set; }
[DataMember(Name = "names")]
public List<string> names { get; set; }
}
[DataContract]
public class Instruction
{
[DataMember(Name = "maneuverType")]
public string maneuverType { get; set; }
[DataMember(Name = "text")]
public string text { get; set; }
}
[KnownType(typeof(double[]))]
[DataContract]
public class ManeuverPoint
{
[DataMember(Name = "type")]
public string type { get; set; }
[DataMember(Name = "coordinates")]
public List<double> coordinates { get; set; }
}
[DataContract]
public class Hint
{
[DataMember(Name = "hintType")]
public object hintType { get; set; }
[DataMember(Name = "text")]
public string text { get; set; }
}
[KnownType(typeof(Detail[]))]
[KnownType(typeof(Instruction))]
[KnownType(typeof(Hint[]))]
[KnownType(typeof(ManeuverPoint))]
[KnownType(typeof(string[]))]
[DataContract]
public class ItineraryItem
{
[DataMember(Name = "compassDirection")]
public string compassDirection { get; set; }
[DataMember(Name = "details")]
public List<Detail> details { get; set; }
[DataMember(Name = "exit")]
public string exit { get; set; }
[DataMember(Name = "iconType")]
public string iconType { get; set; }
[DataMember(Name = "instruction")]
public Instruction instruction { get; set; }
[DataMember(Name = "maneuverPoint")]
public ManeuverPoint maneuverPoint { get; set; }
[DataMember(Name = "sideOfStreet")]
public string sideOfStreet { get; set; }
[DataMember(Name = "tollZone")]
public string tollZone { get; set; }
[DataMember(Name = "towardsRoadName")]
public string towardsRoadName { get; set; }
[DataMember(Name = "transitTerminus")]
public string transitTerminus { get; set; }
[DataMember(Name = "travelDistance")]
public double travelDistance { get; set; }
[DataMember(Name = "travelDuration")]
public int travelDuration { get; set; }
[DataMember(Name = "travelMode")]
public string travelMode { get; set; }
[DataMember(Name = "signs")]
public List<string> signs { get; set; }
[DataMember(Name = "hints")]
public List<Hint> hints { get; set; }
}
[KnownType(typeof(ActualEnd))]
[KnownType(typeof(ActualStart))]
[KnownType(typeof(ItineraryItem[]))]
[DataContract]
public class RouteLeg
{
[DataMember(Name = "actualEnd")]
public ActualEnd actualEnd { get; set; }
[DataMember(Name = "actualStart")]
public ActualStart actualStart { get; set; }
[DataMember(Name = "itineraryItems")]
public List<ItineraryItem> itineraryItems { get; set; }
[DataMember(Name = "travelDistance")]
public double travelDistance { get; set; }
[DataMember(Name = "travelDuration")]
public int travelDuration { get; set; }
}
[KnownType(typeof(RouteLeg[]))]
[KnownType(typeof(double[]))]
[DataContract(Namespace = "http://schemas.microsoft.com/search/local/ws/rest/v1", Name = "Location")]
public class Resource
{
[DataMember(Name = "__type")]
public string __type { get; set; }
[DataMember(Name = "id")]
public List<double> bbox { get; set; }
public string id { get; set; }
[DataMember(Name = "distanceUnit")]
public string distanceUnit { get; set; }
[DataMember(Name = "durationUnit")]
public string durationUnit { get; set; }
[DataMember(Name = "routeLegs")]
public List<RouteLeg> routeLegs { get; set; }
[DataMember(Name = "travelDistance")]
public double travelDistance { get; set; }
[DataMember(Name = "travelDuration")]
public int travelDuration { get; set; }
}
[KnownType(typeof(Resource[]))]
[DataContract]
public class ResourceSet
{
[DataMember(Name = "estimatedTotal")]
public int estimatedTotal { get; set; }
[DataMember(Name = "resources")]
public List<Resource> resources { get; set; }
}
[KnownType(typeof(ResourceSet[]))]
[DataContract]
public class RootObject
{
[DataMember(Name = "authenticationResultCode")]
public string authenticationResultCode { get; set; }
[DataMember(Name = "brandLogoUri")]
public string brandLogoUri { get; set; }
[DataMember(Name = "copyright")]
public string copyright { get; set; }
[DataMember(Name = "resourceSets")]
public List<ResourceSet> resourceSets { get; set; }
[DataMember(Name = "statusCode")]
public int statusCode { get; set; }
[DataMember(Name = "statusDescription")]
public string statusDescription { get; set; }
[DataMember(Name = "traceId")]
public string traceId { get; set; }
}
public async void MakeRequest(string requestUrl)
{
try
{
HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
using (HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse)
{
if (response.StatusCode != HttpStatusCode.OK)
throw new Exception(string.Format(
"Server error(HTTP {0}:{1}.",
response.StatusCode,
response.StatusDescription));
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(RootObject));
object objResponse = jsonSerializer.ReadObject(response.GetResponseStream());
root = (RootObject)objResponse;
}
}
catch (Exception ex)
{
ThrowException(ex);
}
}
The problem is here:
"estimatedTotal": 1,
"resources": [
{
"__type": "Route:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
"bbox": [
32.715692,
-122.420697,
37.827532,
-117.161052
],

Take a look at this blog post: http://rbrundritt.wordpress.com/2012/01/06/bing-maps-rest-service-net-libraries/
It has all the libraries you need for serializing the REST services. For the error you are seeing you need to create a class called Route and mark it as a known type on the resource class.
For Example:
[DataContract]
[KnownType(typeof(Location))]
[KnownType(typeof(Route))]
public class Resource

Related

Can't convert from model to viewmodel, using AutoMapper asp.net core

I am using Auto mapper to map between modelviews and models. I have followed the same steps given by the Auto mapper documentation and still can't find where the issue is.
public class RegisterStaffViewModel
{
public int Id { get; set; }
[Required(ErrorMessage = "StaffName Required")]
public string StaffName { get; set; }
[Required(ErrorMessage = "Gender Required")]
public string Gender { get; set; }
[Required(ErrorMessage = "Address Required")]
public string Address { get; set; }
[Required(ErrorMessage = "StaffCode Required")]
public string StaffCode { get; set; }
[DisplayName("Department")]
[Required(ErrorMessage = "Department is Required")]
public int? DepartmentId { get; set; }
public string CardNo { get; set; }
[Required(ErrorMessage = "Mobileno Required")]
[RegularExpression(#"^(\d{10})$", ErrorMessage = "Wrong Mobileno")]
public string MobileNo { get; set; }
[Required(ErrorMessage = "EmailID Required")]
[RegularExpression(#"^([a-zA-Z0-9_\-\.]+)#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Please enter a valid e-mail adress")]
public string Email { get; set; }
public DateTime EntryDate { get; set; }
[Display(Name = "Position")]
[Required(ErrorMessage = "Position is Required")]
public int? PositionId { get; set; }
[Display(Name = "Staff Type")]
[Required(ErrorMessage = "Staff Type is Required")]
public int? StaffTypeId { get; set; }
public string CardIdNo { get; set; }
public bool? IsDeleted { get; set; }
public bool? IsUpdated { get; set; }
public string CreatedBy { get; set; }
public string UpdatedBy { get; set; }
public string DeletedBy { get; set; }
public string Remarks { get; set; }
public virtual ApplicationUser CreatedByNavigation { get; set; }
public virtual ApplicationUser DeletedByNavigation { get; set; }
public virtual Departments Department { get; set; }
public virtual Positions Position { get; set; }
public virtual StaffTypes StaffType { get; set; }
public virtual ApplicationUser UpdatedByNavigation { get; set; }
public virtual ICollection<AttendanceRecorderViewModel> AttendanceRecorder { get; set; }
public virtual ICollection<ManageLeavesViewModel> ManageLeaves { get; set; }
public virtual ICollection<RegisterDevicesViewModel> RegisterDevices { get; set; }
}
=============================================================================================
public partial class RegisterStaffs
{
public int Id { get; set; }
public string StaffName { get; set; }
public string Gender { get; set; }
public string Address { get; set; }
public string StaffCode { get; set; }
public int? DepartmentId { get; set; }
public string CardNo { get; set; }
public string MobileNo { get; set; }
public string Email { get; set; }
public DateTime EntryDate { get; set; }
public int? PositionId { get; set; }
public int? StaffTypeId { get; set; }
public string CardIdNo { get; set; }
public bool? IsDeleted { get; set; }
public bool? IsUpdated { get; set; }
public string CreatedBy { get; set; }
public string UpdatedBy { get; set; }
public string DeletedBy { get; set; }
public string Remarks { get; set; }
public virtual ApplicationUser CreatedByNavigation { get; set; }
public virtual ApplicationUser DeletedByNavigation { get; set; }
public virtual Departments Department { get; set; }
public virtual Positions Position { get; set; }
public virtual StaffTypes StaffType { get; set; }
public virtual ApplicationUser UpdatedByNavigation { get; set; }
public virtual ICollection<AttendanceRecorder> AttendanceRecorder { get; set; }
public virtual ICollection<ManageLeaves> ManageLeaves { get; set; }
public virtual ICollection<RegisterDevices> RegisterDevices { get; set; }
}
============================================================================================
public interface IMapperConfig
{
IMapper CreateMapper();
}
public class MapperConfig : IMapperConfig
{
public IMapper CreateMapper()
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<RegisterStaffs, RegisterStaffViewModel>();
cfg.CreateMap<AttendanceRecorder, AttendanceRecorderViewModel>();
cfg.CreateMap<ManageLeaves, ManageLeavesViewModel>();
cfg.CreateMap<RegisterDevices, RegisterDevicesViewModel>();
});
return config.CreateMapper();
}
}
==========================================================================================
public async Task<ReturnResult<List<RegisterStaffViewModel>>> GetAllEmployees()
{
var result = new ReturnResult<List<RegisterStaff>>();
try
{
var employees = await context.RegisterStaffs.Where(x => (bool)!x.IsDeleted).OrderByDescending(x => x.EntryDate).AsNoTracking().ToListAsync();
// **here is the error**
result.Success(mapper.Map<List<RegisterStaffs>, List<RegisterStaffViewModel>>(employees));
}
catch(Exception ex)
{
}
return result;
}
============================================================================================
public class ReturnResult<T>
{
public ReturnResult()
{
ErrorList = new List<string>();
}
public bool IsSuccess { get; set; }
public HttpCode HttpCode { get; set; }
public T Data { get; set; }
public List<string> ErrorList { get; set; }
/// <summary>
/// Set success result with data
/// </summary>
/// <param name="Data"></param>
public void Success(T Data)
{
this.IsSuccess = true;
this.HttpCode = HttpCode.Success;
this.Data = Data;
}
/// <summary>
/// Set Server Error result with error message
/// </summary>
/// <param name="Error"></param>
public void ServerError(string Error)
{
this.IsSuccess = false;
this.HttpCode = HttpCode.ServerError;
this.ErrorList.Add(Error);
}
/// <summary>
/// Set Not Found result with error message
/// </summary>
/// <param name="Error"></param>
public void NotFound(string Error)
{
this.IsSuccess = false;
this.HttpCode = HttpCode.NotFound;
this.ErrorList.Add(Error);
}
}
I found the issue was here
var result = new ReturnResult<List<RegisterStaff>>();
i have changed it to
var result = new ReturnResult<List<RegisterStaffViewModel>>();

Html.DropDownListFor: NullReferenceException

I have the following razor code:
<div class="value"> #Html.DropDownListFor(
model => model.physicalAtributtes.bloodGroup,
new SelectList(Model.physicalAtributtes.BloodGroups)
)
</div>
And I have the following Model:
public class Donor
{
public PersonalData personalData { get; set; }
public PhysicalAtributtes physicalAtributtes { get; set; }
}
public class PersonalData
{
public string name { get; set; }
public string adress { get; set; }
public DateTime birthDate { get; set; }
public string bornCity { get; set; }
public string citizenIdentifier { get; set; }
public string nationality { get; set; }
public string profession { get; set; }
public string academicDegree { get; set; }
public string maritalStatus { get; set; }
public int sonsNumber { get; set; }
}
public class PhysicalAtributtes
{
private ArrayList bloodGroups = new ArrayList { "A+", "A-", "AB+", "AB-", "B+", "B-", "O+", "O-" };
public double height { get; set; }
public double weight { get; set; }
public string skinColor { get; set; }
public string eyesColor { get; set; }
public string hairColor { get; set; }
public string hairTexture { get; set; }
public string bloodGroup { get; set; }
public string ethnicity { get; set; }
public ArrayList BloodGroups { get => bloodGroups; set => bloodGroups = value; }
}
The IISExpress gives the following error and I'm not understanding why:
An unhandled exception occurred while processing the request.
NullReferenceException: Object reference not set to an instance of an
object.
AspNetCore._Views_Donor_Register_cshtml+d__0.MoveNext()
in Register.cshtml, line 96
Anyone have a idea what I'm doing wrong?

ServiceStack, OrmLite Issue Saving Related Entities

I've searched for a while looking for a solution to this problem and haven't found anything.
I'm trying to POST a Client DTO and it's related Contacts DTOs to my ServiceStack web service but I'm getting an error. I've followed along with the OrmLite tests located here.
My DTOs:
public partial class Client {
[AutoIncrement]
public int ID { get; set; }
public string Street { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
public decimal? Latitude { get; set; }
public decimal? Longitude { get; set; }
public string HomePhoneAreaCode { get; set; }
public string HomePhoneExchange { get; set; }
public string HomePhoneNumber { get; set; }
public string HomeFaxAreaCode { get; set; }
public string HomeFaxExchange { get; set; }
public string HomeFaxNumber { get; set; }
public string KeyNumber { get; set; }
public string AlarmCode { get; set; }
public string GarageDoorCode { get; set; }
public string MyAPCUsername { get; set; }
public string MyAPCPassword { get; set; }
public bool IsActive { get; set; }
public string Notes { get; set; }
[Reference]
public List<Contact> Contacts { get; set; }
}
public partial class Contact {
[AutoIncrement]
public int ID { get; set; }
public int ClientID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string WorkPhoneAreaCode { get; set; }
public string WorkPhoneExchange { get; set; }
public string WorkPhoneNumber { get; set; }
public string MobilePhoneAreaCode { get; set; }
public string MobilePhoneExchange { get; set; }
public string MobilePhoneNumber { get; set; }
public bool CanSMS { get; set; }
public string PersonalEmail { get; set; }
public string WorkEmail { get; set; }
public string AlternateEmail { get; set; }
public int Ordinal { get; set; }
[Reference]
public Client Client { get; set; }
}
In my Service:
public int Post(Client client) {
Db.Save(client, references: true);
return client.ID;
}
And my test code:
var newClient = new Client {
Street = "1234 Any Avenue",
City = "Gorham",
State = "ME",
ZipCode = "22222",
HomePhoneAreaCode = "123",
HomePhoneExchange = "456",
HomePhoneNumber = "7890",
HomeFaxAreaCode = "098",
HomeFaxExchange = "765",
HomeFaxNumber = "4321",
KeyNumber = "99",
AlarmCode = "1234",
GarageDoorCode = "abcd",
IsActive = true,
Notes = "These are the notes for the new client.",
Contacts = new List<Contact>() {
new Contact { FirstName = "John", LastName = "Doe", PersonalEmail = "john.doe#gmail.com", CanSMS = true, Ordinal = 1 },
new Contact { FirstName = "Jane", LastName = "Smith", PersonalEmail = "jane.smith#gmail.com", CanSMS = false, Ordinal = 2 }
},
};
// POST entity
int newClientID = serviceClient.Post<int>(newClient);
The last line produces the error -
WebServiceException, message "Cant find 'ClientId' Property on Type 'Contact'"
I've tried different combinations of the Reference, References, and ForeignKey attributes to no avail.
Any help would be appreciated.
Thanks,
Jay

How to match entities with stored procedure results(ASP.Net MVC with entity framework)

I am calling one stored procedure which will takes 5 inputs and will returns a set of table data. I have created the class to match with the stored procedure results. How to map this stored procedure result with class?
My stored procedure will takes 6 parameters like below
PROC_REZ_GETCHNAVL 7012,3,20130816,20130817,1,'INR'
and it will gives the table set which will exactly same as below table.
public class AvailableRooms
{
[Required]
[Key]
public int CUSTCODE { get; set; }
public int CHANNID { get; set; }
public string RATECODE { get; set; }
public int RUNSRLNUB { get; set; }
public string ROOMTYPE { get; set; }
[Display(Name = "Room Name")]
public string ROOMNAME { get; set; }
public string ROOMSHTDESC { get; set; }
public string ROOMLNGDESC { get; set; }
public string ROOMFEATURES { get; set; }
public int MAXADT { get; set; }
public int MAXCHD { get; set; }
public int TOTROM { get; set; }
public char AVLFLG { get; set; }
public int AVLROM { get; set; }
public decimal OCCPER { get; set; }
public string RATETYPE { get; set; }
public string RATEPLAN { get; set; }
public string RATEDESCRP { get; set; }
public string RUNDAT { get; set; }
[Display(Name = "Room Rate")]
public decimal SGLRAT { get; set; }
public decimal DBLRAT { get; set; }
public decimal TRPRAT { get; set; }
public decimal QUDRAT { get; set; }
public decimal ADTRAT { get; set; }
public decimal CHDRAT { get; set; }
public decimal PLNSGLRAT { get; set; }
public decimal PLNDBLRAT { get; set; }
public decimal PLNTRPRAT { get; set; }
public decimal PLNQUDRAT { get; set; }
public decimal PLNEXTADTRAT { get; set; }
public decimal PLNEXTCHDRAT { get; set; }
public string ROOMIMG { get; set; }
public string PRPSHORTDESC { get; set; }
public string PRPLONGDESC { get; set; }
public string PRPFEATURES { get; set; }
public string TERMSCOND { get; set; }
public string CACELPOLICY { get; set; }
public string ROOMVID { get; set; }
public string CHANNELDESC { get; set; }
public int MAXPER { get; set; }
public int EXTPER { get; set; }
public int SEASONCODE { get; set; }
private decimal _SGLTOTRATE;
[DisplayFormat(DataFormatString = "{0:##,###}")]
public decimal SGLTOTRATE
{
get
{
return makeFormat(_SGLTOTRATE);
}
set
{
_SGLTOTRATE = value;
}
}
/// <summary>
/// Room Rate Currency Format
/// </summary>
/// <param name="_sglTotRate"></param>
/// <returns></returns>
private decimal makeFormat(decimal _sglTotRate)
{
if (_sglTotRate.ToString().Contains('.'))
_sglTotRate = Convert.ToDecimal(_sglTotRate.ToString("G29"));
return _sglTotRate;
}
public decimal DBLTOTRATE { get; set; }
public decimal EXTADTTOT { get; set; }
public decimal EXTCHDTOT { get; set; }
public decimal RACKSGL { get; set; }
public decimal RACKDBL { get; set; }
public decimal RACKADT { get; set; }
public decimal RACKCHD { get; set; }
public string MEALTYPE { get; set; }
public int DISSEQ { get; set; }
}
Please let me know how to map this class with stored procedure with DbContext?????
Awaiting for your resply.
Below is the solution for this.
namespace WBE.Repository
{
public class WBERepository : WBEContext,IWBERepository
{
/// <summary>
/// Get All the available rooms with respect to input parameters
/// </summary>
/// <param name="roomAvailInputs"></param>
/// <returns></returns>
public List<RoomInventory> GetRoomInventory(List<InventoryInputs> roomAvailInputs)
{
using (var context = new WBEContext())
{
var CustCode = new SqlParameter
{
DbType = DbType.Int32,
ParameterName = "CSTCOD",
Value = roomAvailInputs[0].CUSTCODE
};
var ChnlCode = new SqlParameter
{
DbType = DbType.Int32,
ParameterName = "CHNCOD",
Value = roomAvailInputs[0].CHNCOD
};
var ArrDate = new SqlParameter
{
DbType = DbType.String,
ParameterName = "ARRDAT",
Value = roomAvailInputs[0].ARRDAT
};
var DepDate = new SqlParameter
{
DbType = DbType.String,
ParameterName = "DEPDAT",
Value = roomAvailInputs[0].DEPDAT
};
var NoRooms = new SqlParameter
{
DbType = DbType.Int32,
ParameterName = "NBROOM",
Value = roomAvailInputs[0].NBROOM
};
var CurType = new SqlParameter
{
DbType = DbType.String,
ParameterName = "CURTYP",
Value = roomAvailInputs[0].CURTYP
};
return context.Database.SqlQuery<RoomInventory>
("PROC_REZ_GETCHNAVL #CSTCOD, #CHNCOD, #ARRDAT, #DEPDAT, #NBROOM, #CURTYP",
CustCode, ChnlCode, ArrDate, DepDate, NoRooms, CurType).ToList<RoomInventory>();
}

Retrieving twitter with json

I'm having trouble with parsing a twitter flow, this code is returning this error message:
No parameterless constructor defined for type of
'System.Collections.Generic.IEnumerable`1[[Xxxx.Website.Templates.WidgetViews.Tweet,
Dolphin, Version=1.0.4801.24288, Culture=neutral,
PublicKeyToken=null]]'.
I would very much appreciate your help!
public partial class TwitterWidgetView
{
protected override void OnLoad(System.EventArgs e)
{
string listName = "sas";
string twitterListPath = "https://search.twitter.com/search.json?q=" + listName;
WebClient wc = new WebClient();
var json = wc.DownloadString(twitterListPath);
JavaScriptSerializer ser = new JavaScriptSerializer();
var tweetList = ser.Deserialize<IEnumerable<Tweet>>(json);
}
}
public class Metadata
{
public string result_type { get; set; }
}
public class Tweet
{
public Tweet()
{}
public string created_at { get; set; }
public string from_user { get; set; }
public int from_user_id { get; set; }
public string from_user_id_str { get; set; }
public string from_user_name { get; set; }
public object geo { get; set; }
public object id { get; set; }
public string id_str { get; set; }
public string iso_language_code { get; set; }
public Metadata metadata { get; set; }
public string profile_image_url { get; set; }
public string profile_image_url_https { get; set; }
public string source { get; set; }
public string text { get; set; }
public string to_user { get; set; }
public int to_user_id { get; set; }
public string to_user_id_str { get; set; }
public string to_user_name { get; set; }
public long? in_reply_to_status_id { get; set; }
public string in_reply_to_status_id_str { get; set; }
}
public class RootObject
{
public RootObject()
{}
public double completed_in { get; set; }
public long max_id { get; set; }
public string max_id_str { get; set; }
public string next_page { get; set; }
public int page { get; set; }
public string query { get; set; }
public string refresh_url { get; set; }
public List<Tweet> results { get; set; }
public int results_per_page { get; set; }
public int since_id { get; set; }
public string since_id_str { get; set; }
}
Try using a list instead
var tweetList = ser.Deserialize<List<Tweet>>(json);

Resources