json

Serializing business objects as JSON

I'm trying to serialize my business objects into JSON for consumption by a Javascript application. The problem is is that I'm trying to keep my business objects "pure" in the sense they are not aware of data access or persistence. It seems to me that "diluting" my objects with a toJSON() function would go against this goal. On the other ...

Problems with ASP.net JSON Webservice response type

I am attempting to write an ASP.net web service that will be utilized by a jQuery AJAX call. I am absolutely at my wit's end trying to get this to work. I've seen a number of similar questions online but I haven't been able to find a solution that fits. When I attempt to make the ajax call (via jquery) I get a successful response from t...

`json` and `simplejson` module differences in Python

I have seen many a projects use simplejson module than the in builtin Standard Library json. Also there seem to be many different simplejson modules What are the advantages of simplejson and which implementation is good? Why not, just use the standard builtin json module? ...

Fast unsafe easy PHP key-value database?

I need to store JSON strings against string keys (that should be like 255 characters long). Only querying by key is necessary, so basically just a persistent hash table. It doesn't need to be very safe to write to, but should be kind of fast (few thousand writes per second on single box). If two processes happen to try to write the same ...

Pass JSON obj out from parse function? | noob javascript question

I'm trying to pass an object out of a function. Here's my code: <script type="text/javascript"> // finds the head element; creates a script with passed url; appends it to the head function loadJSON(url) { var headID = document.getElementsByTagName("head")[0]; var newScript = document.createElement('script'); newScrip...

Convert js Array() to JSon object for use with JQuery .ajax

Hi, in my app i need to send an javascript Array object to php script via ajax post. Something like this: var saveData = Array(); saveData["a"] = 2; saveData["c"] = 1; alert(saveData); $.ajax({ type: "POST", url: "salvaPreventivo.php", data:saveData, async:true }); Array's indexes are strings and not int, so for t...

Generate different JSON from XML

I am trying to generate some JSON from an XML file, but not a straightforward conversion. I wish to pick and choose bits and have a slightly different structure. I would rather not just concatenate a giant string together and was wondering if there were some decent libraries around to do this. Also, for testing I would like to be able ...

Design Decision - Javascript array or http handler

I'm building a Web Page that allows the user to pick a color and size. Once they have these selected I need to perform a lookup to see if inventory exists or not and update some UI elements based on this. I was thinking that putting all the single product data into multidimensional JavaScript array (there is only 10-50 records for any p...

Best way to encode tuples with json

In python I have a dictionary that maps tuples to a list of tuples. e.g. {(1,2): [(2,3),(1,7)]} I want to be able to encode this data use it with javascript, so I looked into json but it appears keys must be strings so my tuple does not work as a key. Is the best way to handle this is encode it as "1,2" and then parse it into somethi...

Return plain objects in entity framework for serialization

I have been trying out both Linq to Sql and EF in my ASP.NET MVC application. After switching to EF I realized my XML/JSON serialization output has extra cruft. XML: <Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <EntityKey> <EntitySetName>Persons</EntitySetName> <...

Pass multiple arrays to javascript via ajax

To pass an array from PHP to javascript via ajax, I am going to use json_encode, and recieve it on the javascript end. However, I will be returning multiple rows from my MySQL database, and need to return multiple JSON-formatted arrays. One way I thought of doing this was to string the JSON arrays together in php with some obscure charac...

Need to generate an json array, then loop through the values.

Hi, I need to create some sort of a state for a bunch of elements on a page. The stats can be 1 or -1. Now on the server side I will generate a JSON array and put it in my .aspx page like this: var someArray = { 100:-1, 1001:1, 102:1, 103:-1 } How do I loop through each value now in javascript? BTW, is my JSON array format correct?...

jQuery.ajax() + empty JSON object = parse error

I get a parse error when using jQuery to load some JSON data. Here's a snippet of my code: jQuery.ajax({ dataType: "json", success: function (json) { jQuery.each(json, function () { alert(this["columnName"]); }); } }); I get no errors when parsing a non-empty JSON object. So my gues...

AJAX request denied on FIREFOX but not on IE

I need to make an ajax request, IE Works OK, Firefox URI DENIED. I googled and I found the the only way is to use JSON to eliminate and restrictions. Is there some one got any example? Thanks ...

How to force the GInfoWindow to shorten its tail?

In my Google Maps application, which is supposed to be run on mainly on iPhones, hence the 480/320 window resolution, I am displaying some "stuff" in the GInfoWindow information bubbles. The problem is that, sometimes the bubble is too filled with contents that it doesn't fit onto the screen quite the way I'd like it to. Here's an examp...

Controller's Json() Method Not Returning Array

Hi All, I'm just building my first MVC application and hitting a problem trying to perform a search using AJAX/JSON. The problem seems to be that the JSON returned by my controller is not an array meaning that I can't use jQuery's $.each method to iterate over my items. I'm trying to search for a user by e-mail address. I've got a Sear...

Traverse all the Nodes of a JSON Object Tree with JavaScript

I'd like to traverse a JSON object tree, but cannot find any library for that. It doesn't seem difficult but it feels like reinventing the wheel. In XML there are so many tutorials showing how to traverse an XML tree with DOM :( ...

Properly loop through JSON with jQuery

I have the following JSON: { "status" : "success", "0": { "link" : "test1", "img" : "test2", "title" : "test3" }, "1":{ "link" : "test4", "img" : "test5", "title" : "test6" } } Obviously 0 and 1 are objects themselves and I would like a proper way to loop through all data in this object, the 's...

jqGrid, ASP.NET, JSON is Driving me crazy. Please Help.

Hi there - I've been trying to get this to work for days upon days and it seems like one thing after another. Initially, I finally tracked it down to trouble passing ASP.NET dates in the JSON string back to the grid. I am now using JSON.NET and the dates are coming back the way they should be I'm stuck right back where I alwasy seem to b...

Some Parameters in $.ajax not passing

Hi there, I have this function $.ajax({ url:aurl, method:'GET', beforeSend:function(req) {req.setRequestHeader('Authorization', auth);}, cache:false, dataType:"json", error:function() {...}, success:function(t) {...} }); However, the parameters: method beforeSend Cache are ignored by my browsers FF3, IE8 and Chrome. So, whatever i...