JSON! Don’t use StringBuilder

I almost raged by the not-ability of the new .NET 4.0 to accept a single-quote (‘) character, instead, they automatically convert it to its escaping character, makes my JavaScript won’t work.

Well, it happens when I want to feed a FullCalendar control with a definition of activities, its schedule, its property and so and so. The feed is in form of String generated from a StringBuilder for performance reason. Previously I thought it was okay to set it all as a String, to be noted, I was never program in C# before and I not really sure with the behavior of the framework. Turn out, the single quote is converted–for security reason, Microsoft said.

I found out that this is something new that single quote is converted. In the previous .NET version (.NET 2) this behavior is not exist at all.

My supervisor come to see me, I explain that everything was okay. “Whoa… you study and open so much tab what are you looking for?” then I explain my problem. I was researching how to let .NET framework pass a single quote from controller to view. My supervisor went to see my controller, understand it, and then let me show him my CalenderData() function. Then my supervisor said “Hey, don’t use StringBuilder in this case, or any other String. Try to use JSON. You create a class that handle all the required data, then call JSON to return to the ActionResult”

Oh. Nice. Now I know about it. JSON. I also did a little research about it, found that XML is equivalent to JSON. However, ‘they’ should be use in their own respective proper place. Of course it is not preferable to use XML to feed data to a JavaScript array, right?

Okay. I will continue my coding.


2 thoughts on “JSON! Don’t use StringBuilder

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s