json

Query objects with an array (without 3rd party script)

How can you query an object with an array? var myArray = ['A','C'] Using myArray, how can I get a returned array with ['1','3'] out of the following (previously JSON object) (without using a third party query script -- unless it's jQuery :) [ { "property1": "1", "property2": "A" }, { "property1": "2", "property2": "B...

Very compact object serialization method

I'm building a realtime action multiplayer game in Flash which is using too much bandwidth because it sends message objects as XML (as required by the Smartfox server). I'm now trying to cut down on that by serializing my objects to strings before feeding them to Smartfox. I've tried JSON but it doesn't help much. Is there another seria...

Json problem in flickr

I have this json but I have no idea how to get 7796249@N02 a:2:{s:4:"user";a:3:{s:2:"id";s:11:"7796249@N02";s:4:"nsid";s:11:"7796249@N02";s:8:"username";a:1:{s:8:"_content";s:9:"ilhan.z.y";}}s:4:"stat";s:2:"ok";} ...

Creating dropdown with the first option only as heading.

I want to create a dropdown in such a way that the first option should be avaialable only as a heading. eg: more Sectors Sector1 Sector2 While displaying the dropdown it should be shown with "more Sectors " as the heading.On clicking the dropdown for selecting a particular option, the option "mor...

hiding attributes from inherited_resources rest methods

I want to use REST in an Rails application that uses inherited_resources, but I want certain properties not to be revealed during json and xml request. Let's call that field 'password'. I know I can overwrite the to_xml and to_json methods and then super :except => [:password] But I would have to do that for to_xml and to_json. Not ...

perl: how to sort a JSON structure on something other than "root" key attributes

Perl: How can I sort a complex structure using JSON::PP ? From the JSON Documentation: As the sorting routine runs in the JSON::PP scope, the given subroutine name and the special variables $a, $b will begin 'JSON::PP::'. Here is my attempt, does not seem to work open my $fh, ">", $file or warn " exportAsJSON: can't open f...

JSON to Objects in java?

Does anyone know if there is the ability to generate objects for JSON data? I know there are generic JSON object libraries, but I am looking for more specific - similar to how jaxb can convert SOAP definitions or XSDs into an object model. I know there would need to be some sort of JSON definition file (which I do not know if that conce...

DataContractJsonSerializer or JsonTextWriter for arrays

I'd prefer to use Microsofts System.Runtime.Serialization.Json.DataContractJsonSerializer to serialize my objects in JSON so I do not have to reference any third party assemblies. I'm trying to serialize arrays into a JSON string. There maybe just 1 array, with every other entry being the name and other being the value. e.g.[ "name1", "...

What is the easiest way to pass multiple variables in JQuery?

I have a form that uses a JQuery Json post. I have 10+ textboxes on the page. I have variables passed the only way I know... is there another way to pass multiple variables? $('#nameSubmit').click(function() { var status = document.getElementById('Select2').value; var lob = document.getElementById('LOB').value; var lName =...

Elegant non-const reference to a QVariantMap node?

Basically I need to generate a nested QVariantMap. (Think JSON): { "foo" : 1, "bar" : { "node" : 0 } } I do this in Qt this way: QVariantMap r, r_bar; r["foo"] = QVariant(1); r_bar["node"] = QVariant(0); r["bar"] = r_bar; Which is very inconvenient for large nested structures. Is there an elegant way of doing this, such as this (...

JSON. How many elements are acceptable?

I am running a Facebook application that asks users questions. When they complete one question they move onto another. What I thought about is when they first hit the application the script pulls 300 questions from the database and loads them into either and array or JSON in Javascript. In either case (Array or JSON), how many elements...

Access raw JSON from inside asp.net WebMethod

I have a System.Web.Services.WebService containing several WebMethods. If any of these WebMethods raises an exception, I want to log the values passed to that WebMethod. I want to handle this in a way that is generic enough that I can use the same method regardless of the number or type of parameters. I thought I would log the raw JSO...

RESTful 1-N optional relationships

I trying to learn how to write RESTful apps in Java using Jersey and Hibernate, and I'm struggling to understand how to handle parent/child type relationships when POSTing data to a Resource. I'm using JSON to exchange data, but I don't think that's particularly relevant to my problem. The example I'm working with models the relationshi...

Cant convert poco object from EF 4 to JSON.

Im working on a mvc 2.0 application using the entity framework. With the entityframework I use the repository pattern with poco objects. To start off with the issue, when I convert an entity object to json I get a circular reference error. After some search I discovered that there are proxy's generated to support lazy loading. If there ...

How to correctly send json data via Net.WebRequest - PowerShell

I am working on a powershell script to post json data to a REST interface and am getting (400) Bad Request on each time. I am new to this, and am unclear as to if/how I should be encoding the data. I know I need to set the contenttype to application/json, but is the encoding choice I am using what is causing my problem, and if so what ...

Jackson (JSON) throws JsonMappingException when Float is null

Hi I am using Spring (with Jackson) and jQuery to pass a form as an object. My pojo includes nullable floats. However, when the fields are empty, Jackson throws an Exeption: org.codehaus.jackson.map.JsonMappingException: Can not construct instance of java.lang.Float from String value '': not a valid double value What do I have to do ...

Can I use an extension method with a Structure in VB.NET?

I am wondering whether I can use DataContractJsonSerializer to serialize a Structure type, or does it have to be a reference/Class type? I have the following code: <Extension()> Public Function ToJSON(ByVal target As Object) As String Dim serializer = New System.Runtime.Serialization.Json.DataContractJsonSerializer(target.GetType...

Why can't i do this iteration with json data?

I tried this, var rows = []; for (var i = 0; i < 10; i++) { rows.push(['row' + i, i]); } data.addRows(rows); This seems to work but when i do the same with json, var data = new google.visualization.DataTable(); data.addColumn('string', 'dbZipcode'); data.addColumn('number', 'countusers'); var rows = [...

What are the pros and cons of XML and JSON?

We're an XML shop (we use both XMPP and RSS/Atom feeds a lot, so I guess we have a little or no choice). Yet, I keep hearing about people who "hate" XML and sometimes refuse to use APIs who can only return XML in favor of JSON. It looks like many many prefer JSON to it, but I'm still not so sure why. Of course, JSON is so much more ligh...

Is there a WSDL-like mechanism for JSON?

My company is using SOAP for web services. Despite my efforts to convince my peers to use JSON, we still ended up using SOAP. WSDL was one of the main reasons (another is their unfamiliarity with JSON). That kind of annoyed me. I love JSON for its simplicity and lightweight, but I also like WSDL which provides the description of the dat...