Tag: json

Custom JSON.stringify fails to Stringify object as whole, but works when iterated one level deep

Hoping someone can spot the error, because I’m having trouble Alright, I built my own JSON.stringify for just custom large objects. It may not be exactly to specification for some edge case things, but’s only meant for stringify on large objects that I’m building myself. Well, it works, and works well for most objects, but […]

Are there any guidelines to structuring a JSON message?

Are there any guidelines specific to design JSON objects so that I can exchange information between server and browser? Usecases like setting up a cookie in browser containing actual data with hash values. Any JSON exchanged between browser and server use these hashes to generate proper data using those stored hashes? -Lalith

Load all background-images at once with JS or CSS?

So right now I have a list with a bunch of Facilities. Each of these facilities has an image property which is simply just the name of it’s image file. For example, facility.image == ‘YogisBarAndGrill’. On pageload, I sent an array of strings (image names) via JSON and try to load all the images before […]

Create object from remote JSON

Have posted before but I think I was a little too specific to gain much interest Original. I am new to javascript and AJAX and have found it difficult to find a simple answer to this question. My goal is to simply parse some remote JSON, giving me an object which I can then use […]

json ajax problem

I am sorry to ask this but i’ve been working on this for hours and I can’t figure it out on my own. I have to use json for part of a project and I was able to get it to work but now it’s not returning it back to the right jsp but instead […]

HTML-escaping the data returned from ajax/json

I’m using ajax to retrieve some data from the backend. I get the result as json. I then use jquery to add it to the page: $(…).append(‘<H3>’ + data.title + ‘</H3>’) And I just realized that the json data is not HTML escaped, which is bad. What should I do? HTML escape all the data […]

jQuery evangelists!

I’m absolutely digging what I’ve been able to do in jQuery. From my perspective there isn’t a lot jQuery can’t do. I’m working on a new project and my plan is to use jQuery heavily with JSON,Ajax and Webservices inside of a ASP.net project. Before I go spouting my opinion about how great jQuery is, […]

How to change the JSON output format and how to support chinese character?

Currently I using the following code to get my JSON output from MySQL. <?php $session = mysql_connect(‘localhost’,’name’,’pass’); mysql_select_db(‘dbname’, $session); $result= mysql_query(‘SELECT message FROM posts’, $session); $somethings = array(); while ($row = mysql_fetch_assoc($result)) { $somethings[] = $row; } ?> <script type=”text/javascript”> var somethings= <?php echo json_encode($somethings); ?>; </script> And the output is: <script type=”text/javascript”> var somethings= […]

Convert XML to JSON (and back) using Javascript

How would you convert from XML to JSON and then back to XML? The following tools work quite well, but aren’t completely consistent: xml2json json2xml Has anyone encountered this situation before?

Backbone Collection fetching throwing id error

I’m trying to figure out Backbone.js and am going through the PeepeCode backbone.js basics video. When I try and fetch the collection in the Chrome’s Javascript console, it throws the following error: Uncaught TypeError: Cannot use ‘in’ operator to search for ‘id’ in [{ here is my json: [{ “id” : “1”, “title”: “Bound – […]