json

Prevent direct access to JSON Web Service

I have a webservice that is used by inserting a piece of javascript into the page. The Javascript scans the page for a certain string and makes a request to my ASP.NET JSON WebService. The javascript then uses the JSON to display some content. What I would idealy like to do is prevent anyone from accessing my JSON service directly. Th...

Cache database data in JSON

I'm using a framework that loads the table structure from the database everytime I open a page. I'm thinking of using JSON files to cache this data, and let PHP parse them when I need it. Is it better than loading data from the database? Are there another ways to do something similar? ...

Is json_decode in PHP guaranteed to preserve ordering of elements when returning an array?

You can pass a boolean to json_decode to return an array instead of an object json_decode('{"foo", "bar", "baz"}', true); // array(0 => 'foo', 1 => 'bar', 2 => 'baz') My question is this. When parsing object literals, does this guarantee that the ordering of the items will be preserved? I know JSON object properties aren't ordered,...

finding json errors with ruby

i am using ruby gems json_pure and when i get parsing errors i am not able to determine the line number where the error is occuring. i was expecting to find a validator written in ruby that would tell me the line number. what is the best ruby approach to finding the json errors quickly? thanks! ...

Creative ways to converting a Collection of objects to a javascript array in c#

Hi, I have a List of users List<Users> and I need to make a javascript array of all the UserID's. I know I can manually build this using a stringbuilder and loop through and then save it to a variable and show it on my asp.net-mvc view page. Any other more creative ways to do this? ...

Converting .NET DateTime to JSON

Hi, My webservice is returning a datetime to a jQuery call. The returned data is /Date(1245398693390)/ How can I convert this to a javascript friendly date? ...

Array of ActiveRecords to JSON

Hi all, I am aware that ActiveRecord provides a to_json method which allows fields to be filtered out of the JSON output using :only and :except. At present I am using the following to format an array from a find as JSON: @customers = Customer.find(:all) ... format.js { render :json => @customers} How would I be able to select the ...

Comment blocks around JSON responses

I've noticed that some web applications return AJAX responses with JSON data embedded within a comment block. For example, this would be a sample response: /*{ "firstName": "John", "lastName": "Smith", "address": { "streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": 10021 }, "phon...

Any good libraries for parsing JSON in Classic ASP?

I've been able to find a zillion libraries for generating JSON in Classic ASP (VBScript) but I haven't been to find ANY for parsing. I want something that I can pass a JSON string and get back a VBScript object of some sort (Array, Scripting.Dictionary, etc) Can anyone recommend a library for parsing JSON in Classic ASP? ...

How to store JSON response in jQuery?

Hi guys! I'd like to store my json response in a global variable so, i could use it through my app without making a getJSON request more than once. var data; $.getJSON("panorama.json",function(json){ data = json.images[0].src; console.log(data); }); console.log(data); If I log it in the actual request its fine, but i get "undefi...

Using grails to connect to a flex web service...

I have a grails application that will be rendering an html page into a pdf file and I have a flex application sitting on a server that is going to accept REST parameters and construct a graph based on the parameters (which will be formatted in JSON). What I want to do is make a call to the flex app with my parameters and have the flex ap...

JSON stringify error on Silverlight event argument

I have the following Silverlight code: [ScriptableType] public partial class Page : UserControl { [ScriptableMember] public event EventHandler<UploadChangedEventArgs> OnFileProgressChanged; private void FileProgressChanged_Click(object sender,RoutedEventArgs e) { // test reasons only OnFileProgressChanged(null...

Compound object in HTML <button> value attribute

If for some reason it were mandatory to associate a <button> with more than one value, is there a good way to do it? For example ... CSV: <button value="Lancelot,Grail,blue">Answer</button> JSON: <button value="{'name':'Lancelot','quest':'Grail','color':'blue'}">Answer</button> In the absence of a good way to do it, is there a ...

iPhone, Core Data and JSON

I have a web site with an API which publishes the information using JSON. I can access this API fine, but I would really like to store the information in an iPhone application using Core Data. Is there a way to hook the Persistent Store to the JSON API so rather than having to keep them in sync using some algorithm I can just use the w...

(Better practice) How do you put JSON result in ASP.net MVC Framework?

Currently I am using the terrific Linq 2 Json.net (by newtonsoft), which is a very great simple tool to generate JSON result in programatic way. But after finishing some projects, I stopped and rethink, should I generate the JSON result in the controller? I mean, in .net MVC framework, it DOES provided a JSONResult as one of the ViewRe...

json problem (valums ajax uploader with zend framework)

Hi, I am using the ajax uploader and the Zend Framework. The Problem is when I am using the json response for the onSubmit. With $this->getHelper('Json')->sendJson($data); I only get a saveas dialog. The problem is that the uploader expects every responste to be "text/html" but the json helper sends "application/json" as mimetype. Wi...

NSDictionary objectForKey return value

I'm using json-framework to create a NSDictionary out of a JSON response. That much works wonderfully. Now, within this JSON payload are one or more objects - let's call them X. Sort of like this in XML: <OBJECTS> <X> ... </x> <X> ... </X> <X> ... </X> </OBJECTS> When I look in the aforementioned NSDictionary ...

How can I convert JSON boolean values for output using XMLout?

There are boolean values in the JSON data structure I am using. When call decode_json to convert it to a Perl data structure and feed to the XMLout function provided by XML::Simple, it throws an error because XMLout does not know how to deal with JSON::XS::Boolean values. Is there a way to convert the JSON::XS::Boolean values in a data ...

How to convert XML to JSON in C++?

I came across How to convert XML to JSON in ASP.NET C# (link) and one in javascript (at goessner.net/download/prj/jsonxml/). But have yet to find one in c++ that takes just a string as input (Or a tinyxml node as I'm using that library). ...

Reporting syntax errors in a JSON object with jQuery and/or Javascript

What the best way to report a syntax error when I'm loading a JSON feed with jQuery? I can establish the error reporting settings like this: error: function(xhr){ alert('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText); } however this function doesn't fire when the URL I've called loads ...