json

How can I "Pretty" format my JSON output in Ruby on Rails?

I would like my JSON output in Ruby on Rails to be "pretty" or nicely formatted. Right now, I call the to_json method and my JSON is all on one line. At times this can be difficult to see if there is a problem in the JSON output stream. Is there way to configure or a method to make my JSON "pretty" or nicely formatted in RoR? Thanks....

Javascript array reference

If I have the following: {"hdrs": ["Make","Model","Year"], "data" : [ {"Make":"Honda","Model":"Accord","Year":"2008"} {"Make":"Toyota","Model":"Corolla","Year":"2008"} {"Make":"Honda","Model":"Pilot","Year":"2008"}] } And I have a "hdrs" name (i.e. "Make"), how can I reference the "data" array instances? seems like data["Ma...

How to represent date and/or time information in JSON?

JSON text (RFC 4627) has unambigious representation of objects, arrays, strings, numbers, Boolean values (literally true or false) and null. However, it has nothing defined for representing time information like date and time of day, which is very common in applications. What are the current methods in use to represent time in JSON given...

Why is the behaviour of datetime in JSON different on different systems (win xp, server 2003)?

My Web Application is split up in a WebGui and an WebService. The WebService is responsible for Business Logic and Database handling. From Javascript in the Browser I request data depending on a date and time that is an input from the Browser. This request gous to an .asmx Url in the WebGui and inside this function the webservice is call...

Debugging my web app with JSON/Firefox - Firefox handling of JSON?

I'm attempting to debug my web application with FireFox3. However, when a JSON feed comes from my application, Firefox wants to open up the "application/json" in a new program. Is there a way to configure FireFox3 to handle JSON like regular text files and open up the JSON in the current tab? Thanks. ...

Overriding a MIME type in Rails

I want to override the JSON MIME type ("application/json") in Rails to ("text/x-json"). I tried to register the MIME type again in mime_types.rb but that didn't work. Any suggestions? Thanks. ...

JSON and ASP.NET MVC

How do you return a serialized JSON object to the client side using ASP.NET MVC via an AJAX call? ...

JSON string to list or other usable format in asp.net 2.0

Hi, I have one JSON that is coming in a string format. I need to store it in a key pair value or something like that. I am using asp.net 2.0 and can not use 3rd party DLL like Newtonsoft.Json.dll. I guess last option will be to use regular expression. Can anybody please help me in this? ...

What is the most flexible serialization for .NET objects, yet simple to implement?

I would like to serialize and deserialize objects without having to worry about the entire class graph. Flexibility is key. I would like to be able to serialize any object passed to me without complete attributes needed throughout the entire object graph. That means that Binary Serialization is not an option as it only works with...

How do you serialize javascript objects with methods using JSON

I am looking for an enhancement to JSON that will also serialize methods. I have an object that acts as a collection of objects, and would like to serialize the methods of the collection object as well. So far I've located ClassyJSON. Any thoughts? ...

Best content type to serve JSONP?

I have a webservice that when called without specifying a callback will return a JSON string using application/json as the content type. When a callback is specified it will wrap the JSON string in a callback function, so it's not really valid JSON anymore. My question is, should I serve it as application/javascript in this case or stil...

Can anyone explain this PHP code using json_encode and json_decode?

$a = '{ "tag": "<b></b>" }'; echo json_encode( json_decode($a) ); This outputs: {"tag":"<b><\/b>"} when you would think it would output exactly the input. For some reason json_encode adds an extra slash. ...

JavaScript data formatting/pretty printer

I'm trying to find a way to 'pretty print' a JavaScript data structure in a human-readable form for debugging. I have a rather big and complicated data structure being stored in JS and I need to write some code to manipulate it. In order to work out what I'm doing and where I'm going wrong, what I really need is to be able to see the d...

Where can I find a Perl module for converting a Perl data structure into a JavaScript one?

e.g. (Mason code): 16 % # convert our @cti data structure into a javascript one 17 var cti = [ 18 % foreach my $cti_category (@cti) { 19 { 20 label: "<% $cti_category->{'label'} %>", 21 value: "<% $cti_category->{'value'} %>", 22 children: [ 23...

What are the merits of CSV and/or JSON and/or XML and/or ??? output in a REST API?

We're currently trying to plan a new developer API for our application and debating the various data formats we should use for interchange. We're also going to be using this API for our official desktop application so we're going to have a working implementation before it goes public. There's a fairly intense discussion going on about ...

How do I integrate the ASP .Net Model View Presenter (MVP) pattern and static page methods marked as [WebMethod]?

In an asp.net application, I would like to combine the use of the Webclient Software Factory (WCSF), and its associated Model View Presenter pattern (MVP), with Page Method, that is static methods on the .aspx Views marked with the [WebMethod] attribute. However, static methods on the aspx page would seem to break the Model View Presen...

How do you Serialize ScriptObjects to JSON to save in Silverlight Isolated Storage?

According to this article (http://msdn.microsoft.com/en-us/library/cc197951(VS.95).aspx) Silverlight 2 Beta 2 supports the DataContractJsonSerializer object. But, when I try to use it VS says "Type 'DataContractJsonSerializer' is not defined". I have a method marked as ScriptableMember that gets called from JavaScript and is passed an O...

NHibernate + JSON/Ajax Parent/Child Relationships? Why no workie?

I have a typical parent/child relationship. Writing news in .NET and adding children works fine, NHibernate plays nice and adds the correct relationships. However, when passing a JSON object from the client to some method that serializes my JSON into the .NET representation, NHibernate seems to get confused. It comes up with the correct ...

JSON editor/formatter?

I've got some JSON data, but it's all on one line. Does anyone know of a web or Windows editor that will format (e.g. indent and insert new lines) this data for me, so I can read it better? Preferably one that uses a GUI to display the JSONinstead of a command-line tool that outputs a reformatted document, for example. ...

Ext.form.FormPanel and form submission

Hello. I've been trying to submit a form with the FormPanel using the Action class Ext defaults to. However, I'd like it to consider the response as a script, not JSON-encoded. Has anyone had any experience on this? ...