json

how to skip undefined properties in JSON?

When I parse JSON fields coming from google maps, etc., it is a mess. Because they are not made specifically for my script I have to verify many details, epecially because the addresses are different in every country. Short question: when the script finds a undefined property the script breaks...error.. How can I verify the property is...

Is there an existing library to parse JSON to Dictionary<String,Object> in .net?

I'd like to be able to parse a string of JSON representing an object into a property bag (like a Dictionary) which I can use in C#. Given this string: { "id":1, "name":"some name", "some parameter":2 } I want to end up with a Dictionary which contains "id", "name", and "some parameter" as keys and 1, "some name", and 2 as values res...

how to send database query result in json and display results in javascript?

Can any one give me example or reference for converting mysql database query results in to json object and send it to javascript file then parse the json and display results in javascript file using jquery? Thanks. ...

jquery with .getJSON

I have 2 forms that share a submit button ("#sbtBtn").click(function() { if($("input[name=license_code]").val()) { //check if #retUser has a value $("#formOne").submit(); } else if ($("input[name=referred_by_text]").val() || $("input[name=broker_text]").val() || $("input[name=email1]").val()) { ...

DeSerializing JSON to C#

I see a lot of simple examples of JSON DeSerialization, but when it comes to anything slightly more complex, there is a lacking of samples. I'm looking at deserializing Responses from GetResponse's API: Simple e.g. { "result" : { "updated" : "1" }, "error" : null } Another: { "result" : null, "error" :...

Using jQuery to post JSON object to Spring 3 controller

I'm trying to POST a JSON object to a controller in Spring 3. I'm getting the following error: 2010-10-20 17:59:14,391 DEBUG [org.springframework.web.servlet.DispatcherServlet] Could not complete request org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized token 'tilI': was expecting 'nu...

How to parse JSON object in Java:

I am trying to parse to JSON object in java. I am posting json key value object using dojo.xhrPost() method as shown below: dojo.xhrPost({ url: /esturl/, handleAs : "text", content : {INST1 : {"0001" : "aa"}, INST2 : {"0002" : "bb"}, INST3 : {"0003" : "cc"}}, load : load(data), error : error }); Now I am readin...

Generating JSON input objects for .Net WebServices

I am testing my web services using the Http Resource Test plugin. For that I need JSON stubs for my web methods. Is there any way I can automatically generate them. For primitive types I can do some regex based replacements in notepad++ on the function signature. But when custom types are being passed as arguments, this requires alot of ...

Rails JSON injection

Hi folks, in Rails 2.3 I always used render :json => { :success => true, :data => @foobar} to send JSON data to my frontend. In Rails 3 I'm using respond_to :json ... respond_with @foobar But what I'm missing: I need the 'success' value within the JSON structure. What's the right way to inject such data into JSON response in Rails...

Declare object and its prototype in a JSON block

I'd like to fake a namespace in Javascript. This can be done as follows: var cars = {}; cars.car = function() { ... } cars.car.prototype = { drive: function() { ... } } Works fine. My question, however, is if I can directly fill the whole namespace with JSON, like this: var cars = { car: function() { ....

Firefox JSON "not well formed" errror on valid JSON

I'm receiving the following error message in Firefox: Error: not well-formed Source File: http://school/courses.booking.add.php?1287657494723 Line: 1, Column: 1 Source Code: {"type":"error","message":"You have already booked this course."} As you can see, the output is valid JSON (it's created by PHP's json_encode() function). And it'...

Rails Json response encoding

I've a rails controller that respond_to JSON with a wrong encoding. The site is correctly setup with UTF-8 encoding and the database as well. The text in my db is well formatted, but in the JSON response, all special characters are set to \ufffd. How can I solve the problem? ...

Parse a large JSON file in ActionScript 3

I need to parse a large trace file (up to 200-300 MB) in a Flex application. I started using JSON instead of XML hoping to avoid these problems, but it did not help much. When the file is bigger than 50MB, JSON decoder can't handle it (I am using the as3corelib). I have doing some research and I found some options: Try to split the fi...

Bundle array of json/File/user-defined objects in Android.

how to bundle array of File objects or array of Json objects or array of user-defined objects in one activity and send it to another and how to access them correctly. ? Primitive types like string is quite easy with Intent in = new Intent(); Bundle bundle = new Bundle(); bundle.putString("name", "test"); in.putExtras(bundle); star...

chars missing in textarea

Hi I have a textarea in a form, the data used ind the field comes from an sql call. When i load the form not all text is displayed, just the first line. But when i press space, inter, backspace or another button, all text is displayed anyone have a solution! /RMalberg ...

Is it possible to make an API call to youtube for a feed in JSON and load it into Flash directly?

If this is possible how can it be done? ...

jQuery how to get body contents out of html reponse

Hi, I have a bit of a problem. I have an ajax request that is sent out to do a database update. A response is then returned that looks like: ... ... </head> <body class="contentpane"> {"id":"27","votes":14,"sum":45,"avg":"3.2"} </body> </html> How can I get the contents of body class "contentpane" and then convert this to a JSON obje...

How do I get JSON data from my RESTful service using JEE 5?

I have a simple RESTful web service written in JEE 5. It works fine but I've decided to output JSON from the GET method. As an initial step I've only add one line of code: ObjectMapper mapper = new ObjectMapper(); That one line results in this error: 48d5-9878-2ef7c0a948c4;|StandardWrapperValve[Jersey Web Application]: PWC1406: Servl...

How can I create a specific Json output for use with Highcharts?

I have a controller in ASP.net MVC outputting a JsonResult like so: return Json(new { [...] }, JsonRequestBehavior.AllowGet); ...that looks like this: "data":{"41_A4N1A-1":0,"41_A4N1A-2":0,"41_C4G1A-1":0,"41_C4G1A-2":0,"41_R2N1S-1":0,... However, Highcharts' docs indicate that the data is expected like this: "data":{"41_A4N1A-1",...

How to make a javascript like Disqus or IntenseDebate

Hello, I want to make an app that can display on any webpage, just like how Disqus or IntenseDebate render on articles & web pages. It will display a mini-ecommerce store front. I'm not sure how to get started. Is there any sample code, framework, or design pattern for these "widgets"? For example, I'd like to display products. Should...