I'm just wondering about "stringify" vs "serialize". To me they're the same thing (though I could be wrong), but in my past experience (mostly with asp.net) I use Serialize()
and never use Stringify()
.
I know I can create a simple alias in Javascript,
// either
JSON.serialize = function(input) {
return JSON.stringify(input);
};
// or
JSON.serialize = JSON.stringify;
but I'm just wondering about the difference between the two and why stringify was chosen.
for comparison purpose, here's how you serialize XML to a String in C#
public static string SerializeObject<T>(this T toSerialize)
{
XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType());
StringWriter textWriter = new StringWriter();
xmlSerializer.Serialize(textWriter, toSerialize);
return textWriter.ToString();
}
JSON.serialize = JSON.stringify
? – Daniel DiPaolo Sep 7 '12 at 15:41ToString();
. There inlies the rub. – Chase Florell Sep 7 '12 at 16:22JSON.serialize(obj).toString();
orjsonObject().toString();
... this way it would look much like my C#... but now I'm over complicating it. – Chase Florell Sep 7 '12 at 16:23