json

Struts:JSON:return multiple objects

Hello Is it possible to return multiple JSON objects in the request header with Struts1? I am presently returning a single JSON objects, however the need now is to return a second data structure. All the client-side processing works perfectly for the single data structure in the single JSON objects, I really do not want to complicate it...

GWT's JSONParser producing incorrect values for numbers.

I'm work with GWT and parsing a JSON result from an ASP.NET webservice method that returns a DataTable. I can parse the result into a JSONvalue/JSONObject just fine. The issue I'm having is that one my columns in a DECIMAL(20, 0) and the values that are getting parsed into JSON aren't exact. To demonstrate w/o the need for a WS call, in ...

JSON undefined in IE7

Hey, I am using the following line of JQuery code: $.get('/ajax/buy', {'categoryname':chosenSelected}, function(data) { data = JSON.parse(data); ... However, when running it on IE7 I get error msg "JSON undefined:". How can I use the parser with compatibility to IE7 (and all major browsers)? Thanks in advance, Joel ...

What is the most efficient way to parse json in jquery?

I am using json data and iterating it through jquery and displaying my results... Using var jsonObj = JSON.parse(HfJsonValue); works in firefox but not in IE6.... HfjsonValue is a json string which is returned from my aspx code behind page... SO i dont use ajax... Any suggestion to get my json parsed better and cross browser one... ...

JavaScript - Building JSON object

Hello, I'm trying to understand how to build a JSON object in JavaScript. This JSON object will get passed to a JQuery ajax call. Currently, I'm hard-coding my JSON and making my JQuery call as shown here: $.ajax({ url: "/services/myService.svc/PostComment", type: "POST", contentType: "application/json; charset=utf-8", data: '{...

Reading JSON string in Jquery

Hi All When i try to read a JSON string like below it goes to endless loop. <script language="javascript"> $(document).ready(function() { $("#Button1").click(function() { var json = "[{'City':'Lucknow','ID':'1'},{'City':'Mumbai','ID':'2'}]"; $.each(json, function() { ...

Js variable to json

There has to be a better way of writing the js in my function.... I need to end up with bare json that looks like this [1095365, 1125504]. Setup of code example; var article = {"Id":0,"dirtyFlags":null,"textAreas":null,"metaData":null,"relatedCIs":[{"Id":1095365,"Type":4},{"Id":1125504,"Type":4}],"clients":[{"Id":992754}]}; myFunction...

how to handle single quote in $.ajax POST (JQuery)?

.ajax({ type: 'POST', url: '..serverices/ajaxserver.asmx', data: 'lname='+ $('#lastname').val() }); return false; if #lastname has a single quote, it throws an error. How to handle it? ...

adding to json property that may or may not exist yet

let say i want to do this var dasboard = {}; var page = "index"; $('.check').click(function(){ $(this).toggleClass("active").siblings().slideToggle('slow', function() { dashboard['pages'][page][$(this).closest('li').attr("id")]['show'] = $(this).is(":hidden") ? 'collapsed' : 'expanded'; }); } i get an error s...

How to format JSON date in Javascript?

I'm passing a date from Ruby to Javascript via JSON. It comes into Javascript as "2010-03-24T10:00:00Z". Now, how the heck do I format that in Javascript? ...

DataContractJsonSerializer produces list of hashes instead of hash

I would expect a Dictionary object of the form: var dict = new Dictionary<string,string>() { {"blah", "bob"}, {"blahagain", "bob"} }; to serialize into JSON in the form of: { "blah": "bob", "blahagain": "bob" } NOT [ { "key": "blah", "value": "bob" }, { "key": "blahagain", "value": "bob"}] What is the reason for what app...

Dynamically Forming a JSON object traversion without using eval.

Given I have the following: (which is dynamically generated and varies in length) associations = ["employer", "address"]; Trying to traverse the JSON object, and wanting to form something like the following: data.employer.address or data[associations[0]][association[1]] Without doing this: eval("data."+associations.join('.')); F...

parse json with ant

I have an ant build script that needs to pull files down from a web server. I can use the "get" task to pull these files down one by one. However, I'd like to be able to get a list of these files first and then iterate over the list with "get" to download the files. The webserver will report the list of files in json format, but I'm n...

looping through JSON array

Hi all. I have recently posted another question which straight away users pointed me in the right direction. $.ajax({ type: 'POST', url: './', data: 'token=' + token + '&re=8', cache: false, timeout: 5000, success: function(html){ auth(html); var JSON_array = eval(html); alert(JSON_a...

How do I send an XML document to an ASP.NET MVC page for manipuation

I have some hierarchical data stored as an multiple XML files on the server according to a vendor's schema. In my ASP.NET MVC (2!) application, I'd like the user to choose one of these hierarchies (i.e. file -- I provide a list in my controller's Index action). When the user selects one to "edit" my edit action should return a page tha...

jQuery and CodeIgniter AJAX with JSON not working

Hello, I trying to make my first AJAX with JSON call using jQuery and CodeIgniter. But for some weird reason it's not working. The jQuery code: var item = "COOL!"; $.post("http://192.168.8.138/index.php/main/test", { "item" : item }, function(data){ alert(data.result); }, "json"); The CodeIgniter code: ...

Yahoo BOSS Question

Hello everyone, I wonna to echo totalresults but somethink is wrong. // Get search results from Yahoo BOSS as an XML* $API = 'http://boss.yahooapis.com/ysearch/web/v1/'; $request = $API . $query .'?format=xml&appid='. APP_ID.'&start='.$start."0"; $ch = curl_init($request); curl_setopt($ch, CURLOPT_RETURNTRANSFER, ...

Using JSON input in Ruby method on Rails

I am using jQuery to make an AJAX call to a ruby method in my controller. The javascript looks something like this: var latLongJSON = { "address": [ {"lat" : 50, "long" : 50} ] }; var returnedAddresses; $.ajax({ type: "GET", data: latLongJSON, url: "map/getaddresses",...

Why does this JSON.parse code not work?

I am trying to pass json encoded values from a php script to a, GnuBookTest.js, javascript file that initiates a Bookreader object and use the values i have passed in via the variable i named "result". The php script is sending the values like: <div id="bookreader"> <div id="BookReader" style="left:10px; right:10px; top:30px; bottom:3...

Using a Javascript Variable & Sending to JSON

Hello all! I'm trying to take a URL's hash value, send it through a function, turn that value into an object, but ultimately send the value to JSON. I have the following setup: function content(cur){ var mycur = $H(cur); var pars = "p="+mycur.toJSON(); new Ajax.Updater('my_box', 'test.php', { parameters: pars }); }...