json

Default Values for JSON in javascript

In the code: slider.init({ foo: "bar" }); var slider={ init:function(data){ } } If I use data.foo, I will get "bar". Supposing I have an optional variable called fish which can be included in the JSON variable. If I reference data.fish, I will be told that it is undefined or an error will be thrown or something. Is there a way th...

How do I produce a JSON string array?

Trying to get a JSON output to work with jqGrid 'userdata' option. The example given in the jqGrid PDF is to produce a JSON result like this; { total: "xxx", page: "yyy", records: "zzz", userdata: {totalinvoice:240.00, tax:40.00}, rows : [ {id:"1", cell:["cell11", "cell12", "cell13"]}, {id:"2",...

Can JavaScriptSerializer exclude properties with null/default values?

I'm using JavaScriptSerializer to serialize some entity objects. The problem is, many of the public properties contain null or default values. Is there any way to make JavaScriptSerializer exclude properties with null or default values? I would like the resulting JSON to be less verbose. ...

how to add json library

i am new to python, on my Mac, when i issue command User:ihasfriendz user$ python main.py Traceback (most recent call last): File "main.py", line 2, in <module> import json ImportError: No module named json I get error on json. how to add this library? i'm using 2.5 (the default came with leopard) ...

How to check if object is empty in PHP?

I'm reading JSON data with PHP and that data contains empty objects (like {}). So the problem is, I have to handle the case when object is empty in different manner but I can't find good enough way to do the check. empty(get_object_vars(object)) looks too scary and very inefficient. Is there good way to do the check? ...

json_ encode - JSON.parse() combination, work well in Firefox but fail in other browsers

Hi I'm using the combination of json_encode (PHP) and JSON.parser (Javascript from json.org) for passing a JSON object from PHP to Javascript, the JSON object may have quotes and double quotes so I'm using addslashes() function in PHP. This combination work well in Firefox but not in other browsers like Safari, Chrome or Internet Explor...

JSON and jQuery help please {question edited} :)

Thought it would be easier if I redid the question, I hope. Thanks again for all your help, and I have this thing working mostly. What I dont get is, if I have the file on my desktop, drag it into a browser then it works. If I upload the same file to my website and visit it, it displays nothing in firefox. Last night it worked in saf...

how to send resposne using Json object

Hello everyone, i am working on a project in which a server page is called through XMLHttp and now i want to retrieve response the called page in json object. and i never used json so i don't have any idea about it so please tell me how i can make json object in my server side vb.net page. ...

how to get JSON object depending on it's value

Is there a way to get a JSON object out of a JSON object array depending on its value? What I've got: $users = [{"id":1, "name":"Some Name"}, {"id":2, "name":"Another Name"}, {"id":3, "name":"Third Name"}]; And what I want is to pull out the user depending on the id. So I might have an AJAX call that sends in user...

PHP : Json decoding question

How do i decode whole feed arround 10k item without memory limit of php? i found a code which break the feed to part: http://pastebin.com/m43c3384f how do modify the code to work with the feed below : GAF_update_projects_vertical_callback({"projects":{"count":2,"items":[{"id":502817,"name":"SEO","url":"http:\/\/www.getafreelancer.com\...

$.ajax misfire in ie6

Hi, I'm using the flickr api to create a simple gallery based on images pulled in by their tag. The gallery is working fine in every browser except ie6. When you navigate to the page (by clicking a link) in ie6, the $.ajax success/error code blocks refuse to fire, however when the page is reloaded, or navigated to directly (by entering...

how to create a json object in vb.net 2005

I want to create a json object in vb.net to send the response back javascript function to do something please tell me if anyone have any idea about it. ...

How to get json_encode() to work with ISO-8859-1 (åäö)

json_encode() wont work for me when I'm using åäö. Why? And how can I get it to work? The php: echo json_encode($arr); The javascript: var theResponse = JSON.parse(xmlHttp.responseText); When I alert() the response, and the response contains å, ä or ö, the response is = NULL Please, help me out... ...

How to return datatable / dataset from c# web service as JSON

I have web services returning strings as JSON by dint of using [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] and calling them from the client with headers Content-type = application/json this was all going well until I needed to return a table of results. I have tried using the code here http://www.west...

Creating JSON in php

It seems like I would be jumping through hoops to move data from MySQL into json via PHP json_encode - the encoding is taken care of, it's the pulling of the related data from the database and ensuring that you have array within array within array setup correctly (code snip below)...is there a json framework or something where you feed i...

Access object's properties in object definition

so I have an object definition that looks like this: var Foo = window.Foo = { MIN_ROWS : 10, MIN_COLS : 10, NUM_ROWS : (function(){ return Math.max( parseInt(this.params.rows) || 0, this.MIN_ROWS); })(), // etc... params: (function(){ /* ... */ })() // parses the GET querystring parameters from the URL and returns as a JSON...

How can I convert Xml to Json and vice versa in c#

I'm supprized that I couldn't find this question here. there seems to be few approches out there but none really seem to work. I found http://james.newtonking.com/projects/json-net.aspx but it very large. Is there a simple way to convert Xml to Json and vice versa? Thanks, ...

Convert a JSON string to object in Java?

Is there a way in Java/J2ME to convert a string, such as: {name:"MyNode", width:200, height:100} to an internal Object representation of the same, in one line of code? Because the current method is too tedious: Object n = create("new"); setString(p, "name", "MyNode"); setInteger(p, "width", 200); setInteger(p, "height", 100); May...

Please help me debug this javascript

Would someone please review this code and tell me why the for loops are going infinite? I need a fresh set of eyes. Thank you! var routeData = [{"id":1,"c1_id":43,"c2_id":56,"cost":20,"c1_x":658,"c1_y":68,"c2_x":568,"c2_y":149,"owned":false},{"id":2,"c1_id":27,"c2_id":56,"cost":25,"c1_x":571,"c1_y":10,"c2_x":568,"c2_y":149,"owned":false...

Rails not accepting JSON in production.

I'm attempting to post a json object to my server, however for whatever reason it doesn't show up in production. In development params.inspect yields ({"format"=>"json", "body"=>"Wtf", "api_key"=>"xxx", "action"=>"comment", "item_id"=>"496", "controller"=>"api"}) And in production I get ({"format"=>"json", "action"=>"comment", "con...