json

Is there Any Off-The-Shelf Json Serialization helper class in .NET BCL?

I need to serialize/de-serialize some objects into/from string and transfer them as just opaque data. I can use XmlSerializer to do it, but generated string looks clumsy and long. So, is there any concise Serializer available in .NET? The first thing coming to my mind is that perhaps .NET should have JSON Serializer, but I cannot find i...

How to handle JSON encoded strings using jQuery

I am currently using Django to construct JSON encoded objects which a retrieved using jQuery.getJSON(). The standard simplejson encoder encodes strings according to the JSON "standard", i.e. any string containing a '/' is translated to '\/'. Therefore if one of my parameters is a url, e.g. http://example.com/image.jpg it is passed to t...

CSRF: can the JSON data returned by a POST request be stolen?

Can the JSON data, returned by a POST request be stolen by a cross-site request forgery attack? ...

Problem when retrieving text in JSON format containing line breaks with jQuery

I'm having a strange problem when retrieving JSON formatted text. I use jQuery post to send some data (also JSON formatted) to the server (running PHP) which works fine. Then, when I request the same data from the server using jQuery get, the callback method never executes. This only occurs when the data is JSON formatted and the data co...

Compression algorithm for JSON encoded packets?

Hi I was just wondering what would be the best compression algorithm to use to compress packets before sending them over the wire? The packets are encoded using JSON. Would LZW be a good one for this or is there something better? ...

JSON security best practices?

While researching the issue of JSON vs XML, I came across this question. Now one of the reasons to prefer JSON was listed as the ease of conversion in Javascript, namely with the eval(). Now this immediately struck me as potentially problematic from a security perspective. So I started doing some research into the security aspects of ...

Loading HTML controls from JSON in JQuery (i.e., reverse of ajax serialiseArray)

I would like to take a set of controls (INPUT, SELECT, TEXTAREA) which are contained within a DIV and send their values as JSON via AJAX to a server. This is easy enough with JQuery's serializeArray. However I then want the server to respond with the same structure of JSON that was sent and re-load the control values using the provided...

How to build DataContractJsonSerialize convenience function

I have a common code of serializing a class object in my 3-4 methods ,So I am thinking to create a common function for that code and call function in all the methods I am doingn this from the following code DataContractJsonSerializer ser = new DataContractJsonSerializer(this.GetType()); MemoryStream ms = new MemorySt...

PHP: __toString() and json_encode() not playing well together

I've run into an odd problem and I'm not sure how to fix it. I have several classes that are all PHP implementations of JSON objects. Here' an illustration of the issue class A { protected $a; public function __construct() { $this->a = array( new B, new B ); } public function __toString() { return j...

How to use JMS Message Transformation in ActiveMQ with Stomp/JSON

I am sending messages in JSON format to an ActiveMQ server. I am trying to use JMS Transformation to transform the JSON encoded object into a true Java Object in hopes of being able to use selectors on the data inside. Here is a link to the documentation on Stomp and Message Transformation. Here is a link to a discussion on the patch wh...

Deserializing JSON objects as List<type> not working with asmx service

I am having trouble deserializing my JSON string. I have a class of type person with public properties for sequence number of type int, first name, and last name. I want to pass an array of these objects in JSON format and have them deserialized as a list so I can loop through them on the server, but ASP.NET says something about not be...

Control serializer in JsonResult aka Json function in ASP.Net MVC?

Is there a way to configure what JSON serializer is used when returning JSON via the JsonResult in the controller: public ActionResult SomeJsonFunction() { var x = SomeModelCode.SomeModelFunction(); return Json(x); } It looks like the default is the JavaScriptSerializer. I would love to be able to use the DataContractJsonSerializ...

Regular expression to parse an array of JSON objects?

I'm trying to parse an array of JSON objects into an array of strings in C#. I can extract the array from the JSON object, but I can't split the array string into an array of individual objects. What I have is this test string: string json = "{items:[{id:0,name:\"Lorem Ipsum\"},{id:1,name" + ":\"Lorem Ipsum\"},{id:2,name:\...

Python human readable object serialization

Hi, i need to store Python structures made of lists / dictionaries, tuples into a human readable format. The idea is like using something similar to pickle, but pickle is not human-friendly. Other options that come to my mind are YAML (through PyYAML and JSON (through simplejson) serializers. Any other option that comes to your mind? T...

dealing with blank non-string data in json and asp.net ajax

I am trying to figure out the best way in an asmx web service to indicate null for a date so that I can insert dbnull.value when the user doesn't enter text into a date field. Currently I have a string field in the class that I am serializing that will serve as the date field. When that string is blank I insert dbnull.value, otherwise ...

Requirements for JSON Parser

I'm thinking about implementing JSON parser for Delphi. What should a good JSON parser do? Any ideas for requirements? I believe it should at least output and process JSON... Looking at XML parsers, should it be more DOM or SAX-like? ...

How to include extra data in the Django serializer response?

Hi, I am trying to make a livesearch with Django and jQuery. What I've done is make the javascript ask for some data with the getJSON function, then I've set up a view in Django that returns a JSON response automated by the Django serializer. And this works well, it returns a json response with the text/javascript content-type. To avoid...

Django serialize to json

I have a django model (schedule) with the class of entity, that is the parent of activity, that is the parent of event. class Entity(models.Model): <...> class Activity(models.Model): <...> team_entity = models.ForeignKey(Entity) <...> class Event(models.Model): <...> activity = models.ForeignKey(Activity) ...

Rails controller does not accept JSON?

Hi All, I am trying to create an ActiveRecord object via a JSON request. However the controller fails to set the variables passed in the parameters in the newly created object. As an example, a person object has two fields: firstname and lastname. The JSON generated by the JSON.stringify function of the JSON.org library produces: {"fi...

Best way to parse JSON data into a ASP.net object?

What's the best way to parse JSON date into and ASP.net object? I am trying to assist a coder friend of mine and he is trying to dump some data from a JSON string into a database using ASP.net. Are there any prebuilt scripts that would make this happen? Thanks in advance to any help. ...