json

How to do peek() in Jackson json library?

I'm using the Streaming API JsonParser of the Jackson library to do some custom json parsing in java. Is there a way of achieving functionality similar to a peek() method, where the next token is returned but the cursor position is not moved forward? The use case for this is similar to the following: JsonParser parser = new JsonFactor...

Jquery: dealing with a json response?

I am having trouble parsing the response from my app. Here is the call with my best guess at how to deal with the json coming back... $.ajax({ url: 'houses.json', method: 'GET', datatype: 'json', success: function(data){ $.each(data, function(h){ $(h).each(function(){ console.log(h....

json_decode() returns null issues

Hey all, I've an issue with my JSON. It works returns correctly in PHP 5.3 (so I can't use json_last_error()), and it returns successfully when I copy string explicitly into json_decode (json_decode('{...}'). It only returns null in when I pass the result as a variable and I'm using php 5.2, which is what I need it for. The output come...

Good resource to learn how to build tables from JSON

So I've spent the past few weeks developing a proof of concept with JSON data. I've been loading the data into tables by building the blank table in HTML and inserting the JSON values data with jQuery's getJSON function like so: $('table#table_fourth_row tr:last td:first').html(data.tableDataCandyStuff.dataYearToDate.timePeriod); $('ta...

iPhone dealing with xml vs soap vs JSON vs RESTful

I do not have much experience coding systems dealing with web-services. Please help me in solving following confusion. One of my clients want me to build an iPhone App that had native UI controls but deals extensively with Web Services. Right from authenticating the user into a network to loading a list of users or anything related in t...

How can I use PHP to get the nth item in a JSON object?

Ok, so the twitter daily trends list is 20 trends long. Let's say I want to get the 7th trend on the list. Here's my longwinded way of doing it... // We want the 7th item in the array $trendArray = 7; // Get an array (?) of the latest twitter trends $jsonurl = "http://search.twitter.com/trends/daily.json"; $json = file_get_contents($js...

Querying and format validation of json (analogous to XSD)

Any good ideas about analogues for XSD (i.e., "schema validation") for JSON? My search engine skills are failing me. (FWIW, I'm coming at it from Python.) ...

Stringify JS Object to JSON (Have Functions stringify into a property)

Is there a function or library that will take a JS Object that has properties and functions and stringify it to JSON but when it comes to a Function, it will change it into a property and call the function to return its value?? function object() { this.property = 12; this.function = function() { return "This"; } } So this wou...

jQuery + JSONP + Yahoo Query Language

I want to get live currency rates from an external source, so I found this great webservice: Currency Convertor This service is working like a charm, the only downside is that it does not provide JSONP results, only XML. Therefore we have a cross browser problem while trying to consume this webservice using jQuery $.ajax(). So I found...

ASP.NET MVC JsonResult return 500

Hi I have this controller method: public JsonResult List(int number) { var list = new Dictionary<int, string>(); list.Add(1, "one"); list.Add(2, "two"); list.Add(3, "three"); var q = (from h in list where h.Key == number select new ...

From object to proper types: Is this the/a "right" way to work with this non-generified, object-returning API?

One particular aspect of some code I've written is causing me minor headaches, I can't pinpoint the reason - all the type checking and casting is making me feel uneasy. The code works as it is right now. I'd like to know wether or not there's a better way to handle the type-specific aspects of the code. I'm using a non-generified, objec...

ie is not understanding 'false' from a JSON string?

I have some php that checks if a user is logged in and returns false, this is then passed via ajax to the browser to let the user know he needs to log in. Works perfect in FF and the alert returns 'true' but in IE, it returns 'null' no matter what I do // Check for logged in user $.getJSON(baseUrl+"index.php/login/checkState", func...

json_decode in PHP to set a cookie..

Hi All, I want to decode Json returned from the WebService, And it should set a cookie, that i want to use to call next WebService API. I am not sure how to set a cookie, and decode this json. I tried decoding it, but get the error. I need to extract sessionId. You can use the WebService.. I have put this on Internet. Here is my code s...

How to iterate over an array of objects in JavaScript?

I'm using PHP to fetch "tasks" from my database and encoding it as JSON. When I transfer the data over to javascript, I end up with something like this: Array { [0] => Task { id: 2, name: 'Random Task', completed: 0 } [1] => Task { id: 8, name: 'Another task', completed: 1 } } etc. I gu...

FreeMarker Template JSON - Give it a node?nextSibling to find out, if the current node have a sibling?

I want to convert a XML File to JSON. The problem is, I have the structure Content ... Secon ... Secon ... Secon ... I want it to the JSON Format like: { "nodeid" : "34", "text" : "First level", "children" : [{ "nodeid" : "1", "text" : "Content ...", "leaf" : true ,"children" : [{ "nodeid" :...

Creating BSON object from JSON string

Hi, I have Java app that takes data from external app. Incoming JSONs are in Strings. I would like to parse that Strings and crate BSON objects. Unfortunate I can't find API for that in Java's BSON implementation. Do I have use external parser for that like GSON? ...

How to loop over a valid JSON

I have made an Ajax request to a PHP script and that PHP script returned this JSON object and when i tested with link text it says it's valid [ { "id_annotation": "1", "annot_doc_id": "page_de_test.html", "annot_id_auteur": "2", "anno_startOffset": "47", "annot_startContainer": "id-aaa", "annot_endOffset": "88",...

jQuery $.each and $.data

Hi, i have a script that calls a php file and gets an JSON object from it. I'm tring to get the ids from the object attached to a specific element that is created by iterating with $.each the json object. Here is what i have done so far: $(document).ready(function() { $("#div2").hide('slow'); $("#div1").empty().html('<img src="a...

How to clean up dodgy JSON file from server

Hi, I'm trying to use a JSON feed from our site, which unfortately is not formated correctly. I can clean up the feed via calling it first via the $.ajax call, but want to be able to pass this cleaned up content back to iterate over as if it was a JSON object. $(document).ready(function() { // use ajax call as json supplied needs c...

How do I append an LI to an UL using jQuery forms.js

I have multiple forms on a page and i'm trying to use jQuery form.js to save each comment that is posted and then append the comment to the UL afterwards. The save part of it is working fine. However, I am having trouble getting the comment to update the UL correctly. See code below: //My Form <form method="post" action="includes/an...