json

How can I post an array of string to ASP.NET MVC Controller without a form?

Hi there, I am creating a small app to teach myself ASP.NET MVC and JQuery, and one of the pages is a list of items in which some can be selected. Then I would like to press a button and send a List (or something equivalent) to my controller containing the ids of the items that were selected, using JQuery's Post function. I managed to ...

Is JSON validation a best practice?

Is it a best practice to validate JSON? With both a JSON schema proposal and a JavaScript implementation of a JSON Schema validator, this practice would seem relatively frictionless to implement. So, is it a no-brainer that should be part of any robust application? Or do you employ other preferred strategies to handle bad JSON? ...

Best way to pass JSON from Browser to PHP using Ajax.Request

Hi I have a JSON object that is a 2-dimentional array and I need to pass it to PHP using Ajax.Request (only way I know how). ...Right now I manually serialized my array using a js function...and get the data in this format: s[]=1&d[]=3&[]=4 etc. .... my question is: Is there a way to pass the JSON object more directly/efficientely?..ins...

How can I get a JsonResult object as a string so I can modify it?

I am using the FlexiGrid jQuery plug in and I need to get a JSON object back form my MVC App, simple enough if the FlexiGrid took just the object but I need to add a few items to the response string for it to work properly with FlexiGrid. So here is a portion of my controller code: If Request.QueryString("json") IsNot Nothing Then ...

How to convert a literal object into user defined object in javascript?

Writing a ton of web applications leveraging JSON/AJAX, I find myself returning tons literal javascript objects (JSON). For example, I may be request all the Cats from GetCats.asp. It would return: [ { 'id': 0, 'name': 'Persian' }, { 'id': 1, 'name': 'Calico' }, { 'id': 2, 'name': 'Tabby' } ] Now, these are all Cat objects wi...

How to post an array of complex objects with JSON, JQuery to ASP.NET MVC Controller

My current code looks like this, how can I pass my array to the controller and what kind of parameters must my controller action accept? function getplaceholders() { var placeholders = $('.ui-sortable'); var result = new Array(); placeholders.each(function() { var ph = $(this).attr('id'); var sections = $(thi...

Json WebService in Asp.net

Hello to everyone how do i create asp.net web service that return JSON fromated data.?? ...

When to prefer JSON over XML?

My requirement is just to display a set of values retrieved from database on a spread. I am using jquery. ...

What is the best way to sync 2 sqlite tables over http and json?

I have a fairly simple sync problem. I have a table with about 10 columns that I want to keep in sync between a sqlite file on 3 different clients: an Iphone client, a browser client, and a Ruby on Rails client. So I need a simple sycing solution that will work for all 3, i.e. I can easily implement it in Javascript, Objective C, and R...

Best way to display data via JSON using jQuery

Hey, i am trying to find the best way to display results on my page via an Ajax call using jQuery, do you think the best way is to pass it as JSON or plain text? I have worked with ajax calls before, but not sure which is preferred over the other and for the JSON version what is the best way to read from a JSON file generated by a PHP p...

Method for displaying "loading" message

I am using jquery and the getJSON method and I am wondering if there is a way to display a message saying loading before it loads my content. i know with the jquery ajax calls there is the before submit callbacks where you can have something but the getJSON only has like three options. Any ideas? Thanks, Ryan ...

How do I serialize a C# anonymous type to a JSON string?

I'm attempting to use the following code to serialize an anonymous type to JSON: var serializer = new DataContractJsonSerializer(thing.GetType()); var ms = new MemoryStream(); serializer.WriteObject(ms, thing); var json = Encoding.Default.GetString(ms.ToArray()); However, I get the following exception when this is executed: Type ...

Get IIS6 to serve JSON files (inc. POST,GET)?

By default, IIS6 does not serve .json (no wildcard MIME type). Therefore a 404 not found is thrown. I then add a new MIME type (.json, text/plain or application/x-javascript or application/json) which works fine. However, when you then add a new mapping (Home Directory -> Configuration -> Add) with .json, C:\WINDOWS\system32\inetsrv\as...

Testing for an empty array object in JSON with jQuery

Hi, I have a request that returns a JSON object with a single property which is an array. How can I test if the array is empty? With jQuery code like: $.getJSON( jsonUrl, function(data) { if (data.RoleOwners == [ ]) { $('<tr><td>' + noRoleOwnersText + '</td></tr>').appendTo...

jQuery .getJSON Firefox 3 Syntax Error Undefined

I'm getting a syntax error (undefined line 1 test.js) in Firefox 3 when I run this code. The alert works properly (it displays 'work') but I have no idea why I am receiving the syntax error. jQuery code: $.getJSON("json/test.js", function(data) { alert(data[0].test); }); test.js: [{"test": "work"}] Any ideas? I'm working on ...

How to test JSON result from Rails functional tests?

As title, I want to assert my AJAX request and test the JSON output, how can I do that? ...

jQuery - $.each loop through json code

Due to the way my serverside script outputs I receive multiple JSON objects. {jsonhere}{jsonhere1}{jsonhere2}{jsonhere3} etc.. They aren't seperated by anything. If I would do a split based }{ I would lose those brackets. So is there an outerloop I can put over the regular $.each loop to make this work? Thank you, Ice ...

Regexp: Remove quotation marks from json list

I've got an array of objects in json format: [{"name":"obj1", "list":["elem1", "elem2", "elem3"]}, {"name":"obj2", "list":["elem4", "elem5", "elem6"]}] Now I'd like to construct regexp to remove quotation marks from around elements in the "list" using javascript. Desirable result: [{"name":"obj1", "list":[elem1, elem2, elem3]}, {"name"...

A better Java JSON library?

Can anyone recommend a good Java JSON library (better than the one from http://json.org/)? I've also found JSON-lib, which definitely looks like an improvement, but I'm wondering if there is anything that is even better than that? ...

Best way to include unobtrusive information on a web page

So I've got some scripts I've written which set up a Google map on my page. These scripts are in included in the <head> of my page, and use jQuery to build the map with markers generated from a list of addresses on the page. However, I have some exact co-ordinate data for each address which the javascript requires to place the markers c...