1

Json libarary to convert data to json

this is my main method which return two list one with property list List and another is List

  public static Tuple<List<RoomDayBook>, List<string>> DayBookRowData(DateTime StartDate, DateTime EndDate, int SupplierId, bool wantSubRoom)
        {
            DataSet dsDayBook = FillDayBookData(StartDate, EndDate, SupplierId);

           ............................ 
           ............................

                lstDayBook.Add(objDayBook);
            }
            return new Tuple<List<RoomDayBook>, List<string>>(lstDayBook, Guests);
        }

In this RoomDayBook class in which i use JsonProperty which give jsonproperty name in json serilization in stand of property name

public class RoomDayBook
{
    [JsonProperty(PropertyName = "RC")]
    public string RoomCode { get; set; }
    [JsonProperty(PropertyName = "RN")]
    public string RoomName { get; set; }
    [JsonProperty(PropertyName = "HS")]
    public bool HasSubRoom { get; set; }
    [JsonProperty(PropertyName = "RD")]
    public List<RoomDetail> RoomDetails { get; set; }
    [JsonProperty(PropertyName = "SRs", NullValueHandling = NullValueHandling.Ignore)]
    public List<RoomDayBook> SubRooms { get; set; }
}

it's woking perfectly in normal aspx webmethods but not working in web api please help me find me reason behind it

2
  • Are you using WCF at all? If not, please remove the wcf tag from this question. Commented Feb 8, 2016 at 23:36
  • no i'm not using WCF Commented Feb 10, 2016 at 14:35

1 Answer 1

0

I found problem in different version of Newton.json library different between class library and Web API Project that's it not convert it in proper format

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.