Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Fixed. YAML sucks, so don't use it. All kinds of Google results about how SnakeYAML is derived from PyYaml and what-not, but nobody clearly states exactly what dumps format from PyYaml works with what loadAll routines with SnakeYAML. </p> <p>Also, performance with YAML is horrid, JSON is far simpler and easier to implement. In Python, where our middleware resides (and most crunching occurs), YAML takes almost twice the time to process than JSON!!</p> <p>If you are using Python 2.6 or greater, just</p> <pre><code> import json json_doc = json.dumps(projects, default=convert_to_builtin_type) print json_doc   def convert_to_builtin_type(obj):  print 'default(', repr(obj), ')'  # Convert objects to a dictionary of their representation  d = { '__class__':obj.__class__.__name__, '__module__':obj.__module__, }  d.update(obj.__dict__)  return d </code></pre> <p>Then on the Java client (loading) side, use GSon -- this took a lot of head-scratching and searches to figure out because ALL examples on the 'net are virtually useless. Every blogger with 500 ads per page shows you how to convert one single, stupid object and last time I created an app, I used lists, arrays, or anything that held more than one object!! </p> <pre><code>try { serverAddress = new URL("http://127.0.0.1:5000/projects/" + ruser.getUserEmail()+"+++++"+ruser.getUserHash()); //set up out communications stuff connection = null; //Set up the initial connection connection = (HttpURLConnection)serverAddress.openConnection(); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setReadTimeout(100000); connection.connect(); //get the output stream writer and write the output to the server //not needed in this example rd = new BufferedReader(new InputStreamReader(connection.getInputStream())); sb = new StringBuilder(); while ((line = rd.readLine()) != null) { sb.append(line + '\n'); } String mystr = sb.toString(); // Now do the magic. Gson gson = new Gson(); projectData = gson.fromJson(mystr, ProjectData[].class); } catch (MalformedURLException e) { e.printStackTrace(); } catch (ProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { //close the connection, set all objects to null connection.disconnect(); rd = null; sb = null; connection = null; } return projectData; </code></pre> <hr> <p>Done! In a nutshell - YAML sucks and use JSON!! Also, the http connection code is mostly snipped off of this site...now I need to figure out https.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload