JSON Dataset Generation

Earlier today, I found the need to generate and make use of a large JSON dataset for populating a list within a mobile app experience. I needed thousands of records to test and all of the sample JSON files I could find were pretty small, simple things. I reached out on Twitter and recieved a few responses, including a rather neat Node-based solution from Ray Camden.

However, after a little more research, I stumbled across a really convenient web-based project called JSON Generator which took care of all my needs quite handily!
Not only did this produce a rich set of data for my use, but you can actually tailor the generator template to your liking through the use of certain bindings accessible via the help menu. Even more importantly, you can bump up the amount of records generated by editing the template as well. I took it from the default 5-7 range to return between 1000-5000 records simply by modifying the following line:

'{{repeat(1000, 5000)}}',

Now I have a rich set of data for use in mobile AIR, PhoneGap, whatever I wish!

Using the native JSON methods in ActionScript 3 to load in and parse the data locally, I was able to easily inject this large dataset into my Feathers list component in testing. For fun, I recorded a short video to demonstrate the performance:


PhoneGap: Saving Arrays in Local Storage

One of a handful of local storage options for PhoneGap applications is the localStorage solution which is actually part of the W3C specs. It provides access to a W3C Storage interface since we are just dealing with HTML5 in PhoneGap. This is a good option for storing simple strings but what if we want to store more complex data structures but don’t want to be bothered with a SQLite database for our application? It’s actually possible to do this via some JSON trickery!

In this example, we will first initialize our Array object to hold all the data:

var gatheredPosts = new Array();

We can then create complex data structures and push these into our array for immediate use in the application – and to back up via local storage options for later. Here’s some dummy code which demonstrates this:

// let's imagine these "posts" come from a remote data call which has just returned
for (var i = 0; i < posts.length; i++) {
    gatheredPosts.push({title:posts[i].title, url:posts[i].url, content:posts[i].content});

At this point, we could attempt to write the array to local storage via the normal method... but this will not work with complex objects like arrays out of the box - and will fail to write the appropriate data:

window.localStorage.setItem("cachedPosts", gatheredPosts);

What we need to do to be able to save and retrieve complex array data is to extend the Storage prototype with new methods which will stringify our array data into JSON and also parse the stringified data into a new data object for retrieval. It's a lot simpler than it sounds. Just include these definitions in your JavaScript:

Storage.prototype.setArray = function(key, obj) {
    return this.setItem(key, JSON.stringify(obj))
Storage.prototype.getArray = function(key) {
    return JSON.parse(this.getItem(key))

We can now use these new methods to properly store and retrieve our array structures!

Here we see array storage:

window.localStorage.setArray("cachedPosts", gatheredPosts);

And array retrieval:

gatheredPosts = window.localStorage.getArray("cachedPosts");

Not a bad solution :)

Edge Code, PhoneGap Build, and lots of Absinthe!


Presented at the Adobe MAX Community Pavilion in Los Angeles, CA on May 8th, 2013.

We’ll be having at look at the Absinthe Dilution Faerie mobile app and how it was created with Adobe Creative Cloud tooling and services. You might even learn a thing of two about Absinthe…



Presented at Adobe MAX 2013: Community Central Show and Tell Theater
[Apologies for the audio quality and image distortion. Recorded locally with built-in mic.]

Adobe MAX: Community Central Show and Tell Theater

There arn’t the normal set of unconferences this year as normally found at MAX; FITC, 360, and others are pretty well absent from the community pavilion this time around. The good news is that thee is a new community based effort this year: the Show and Tell Theater! Here, people from Adobe and the community can share some cool projects they are working on in a lounge setting on the Adobe MAX Community Pavilion floor. The Show and Tell Theater is located within Community Central.

Schedule is up on the Adobe MAX blog.

Am I participating in this? Yes, I am:

Absinthe Dilution Faerie

Edge Code, PhoneGap Build, and lots of Absinthe!
We’ll be having at look at the Absinthe Dilution Faerie mobile app and how it was created with Adobe Creative Cloud tooling and services. You might even learn a thing of two about Absinthe…

Wednesday, May 8th 2013 2:40 PM in the Community Pavilion!

I’m also speaking on Edge Animate! Be sure and register for my session… there is still time but it is FILLING UP FAST!

BTW: Very possible I’ll be doing a book giveaway as well…


Review: PhoneGap 2.x Mobile Application Development Hotshot

8581OS_PhoneGap Cookbook_cov
I’ve been working a lot with PhoneGap lately for both personal projects and teaching. Because of this, I’ve taken some time to check out some of the newer books on the subject. The last book I’ve had a chance to look over is the PhoneGap 2.x Mobile Application Development Hotshot published by Packt (Packt being the publisher of my latest book as well – Learning Adobe Edge Animate).

The book itself is just under 400 pages and is structured in an interesting way because every chapter is a different PhoneGap project. These projects include some really great examples of localization, GPS and mapping, file system usage, media generation and consumtion, integration with social networks, even a chapter on using native components within PhoneGap.

One thing about this book is that it seems to be authored in a way where you would want some experience with PhoneGap first – as it is entirely project focused. I’d suggest pairing it with something like Matt Gifford’s PhoneGap Mobile Application Development Cookbook, or take Ryan Stewart’s excellent Lynda.com course: Up and Running with PhoneGap.