I have created a javascript object. In my app I'm setting values to the different properties of that object.
I have a WCF service that I want to pass the parameter object to. From what I understand I should be able to use JSON.stringify() to do this.
So if my WCF service has a Person object parameter defined as:
public class Person
{
public string FirstName;
public string LastName;
}
and I have created a Person javascript object as:
var person =
{
"FirstName":"Jack",
"LastName":"Johnson"
};
then I should be able to use: JSON.stringify(person) in my javascript in order to generate a JSON parameter I can pass through a jquery ajax call to my WCF service.
The problem is when I call JSON.stringify() in my code I get a js error during runtime: "Microsoft JScript runtime error: 'JSON' is undefined."
So what do I need to do to be able to use JSON.stringify? I read a post saying that stringify may not be supported by jquery 1.4.1 and I added a reference to Crockford's json2.js file but I'm still getting the error. Can someone please shed some light on this?