JSONH
An story in mobile API optimisation & how to get data
stuff faster.
Tuesday, 1 April 14
Tuesday, 1 April 14
Back in the day when I could barely pronounce API and for me,
JavaScript was some esoteric magic that ...
Tuesday, 1 April 14
Mobile phones were unwieldy bricks of plastic and metal with huge antennas and then hefty
charge
W.A.P...
Tuesday, 1 April 14
Actually taking to where what's the point of this well today, you see, we have a
super bit, quadruple ...
Tuesday, 1 April 14
But then came the iPhone followed by nestle droid sorry android and the rabbit holes
appeared we devel...
Cost of an API call
Tuesday, 1 April 14
I was looking for only that I wanted to increase performance speed
reducing packet...
Mobile API query
TELCO WIFI
MIDDLEWARE SERVER
DATA BACKBONE
API PROVIDER DATA SOURCE
Cost of an
HTTP
REQUEST...
Tuesday, 1...
JSONH
JSON compression search
CJSON & JSON w HPack (now JSONH)
JSONH for Homogenous Collections
http://web-resource-optimi...
Compression Comparison
JSONH looked best.
Tuesday, 1 April 14
Setting Up - 1
GET JSONH library
GET JSONminify (optional to strip whitespace/
comments)
Add both libraries into your proj...
Setting Up - 2
Include the libs into your
Node.ACS/Ti App / Server
Minify & pack the data
Return string
var jsonminify = r...
Setting Up - 3
decompress collection in
app
! function callback(e) {
! ! Ti.API.log('mobile request callback');
! ! var rJ...
ACS/AWS
3rd Party
Service API Method
Stringify Reponse
Minify Reponse
pack JSONH
homogenous
collection node
Mobile Functio...
Upcoming SlideShare
Loading in …5
×

JSONH & Mobile APIs

573 views

Published on

London Titanium talk on compressing JSON responses

Published in: Software, Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
573
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
2
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

JSONH & Mobile APIs

  1. 1. JSONH An story in mobile API optimisation & how to get data stuff faster. Tuesday, 1 April 14
  2. 2. Tuesday, 1 April 14 Back in the day when I could barely pronounce API and for me, JavaScript was some esoteric magic that induced pain and wonder.
  3. 3. Tuesday, 1 April 14 Mobile phones were unwieldy bricks of plastic and metal with huge antennas and then hefty charge W.A.P was the new kid on the block and I had to print out yet another manual to accompany my hefty collection of mySQL 3.x and HTML / HTTP specs I can remember that it filled me with hope & excitement period and helped cross the bridge between our flashy web bracket plan intended bracket and these always connected devices with screens the size of stamps
  4. 4. Tuesday, 1 April 14 Actually taking to where what's the point of this well today, you see, we have a super bit, quadruple powered Infinity Gauntlet charged broadband speeds... It's made us a little lazy KiloBytes?... pah! Peanuts four our broadband connected society…
  5. 5. Tuesday, 1 April 14 But then came the iPhone followed by nestle droid sorry android and the rabbit holes appeared we developers dived in red pill please and our complacency led us to grow home bellies Not really but my point is this to be really care or understand how user base not only in the first I know we do so how can we improve our code designs technical debt and get out of a lazy programming interface frame of mind
  6. 6. Cost of an API call Tuesday, 1 April 14 I was looking for only that I wanted to increase performance speed reducing packet size & cost of an API call. Specifically for a mobile project talking to a node.ACS service interacting with one or more APIs
  7. 7. Mobile API query TELCO WIFI MIDDLEWARE SERVER DATA BACKBONE API PROVIDER DATA SOURCE Cost of an HTTP REQUEST... Tuesday, 1 April 14 EXPLAIN DIAGRAM & MULTIPLE REQUESTS
  8. 8. JSONH JSON compression search CJSON & JSON w HPack (now JSONH) JSONH for Homogenous Collections http://web-resource-optimization.blogspot.co.uk/2011/06/json- compression-algorithms.html A collection of objects with the same dynamic type. Arrays are the most common homogeneous collection objects. David J. Barnes Tuesday, 1 April 14
  9. 9. Compression Comparison JSONH looked best. Tuesday, 1 April 14
  10. 10. Setting Up - 1 GET JSONH library GET JSONminify (optional to strip whitespace/ comments) Add both libraries into your project. Add to Node.ACS & into your Ti project Tuesday, 1 April 14
  11. 11. Setting Up - 2 Include the libs into your Node.ACS/Ti App / Server Minify & pack the data Return string var jsonminify = require("jsonminify"); var JSONH = require('jsonh'); ! ! var resString = _minifyJS(data); ! ! resString.Contents = JSONH.pack(resString.Contents); ! ! return (JSON.stringify(resString)); Tuesday, 1 April 14
  12. 12. Setting Up - 3 decompress collection in app ! function callback(e) { ! ! Ti.API.log('mobile request callback'); ! ! var rJson = JSON.parse(e); ! ! // get return data and parse then unpack the JSON. ! ! rJson.Contents = JSONH.unpack(rJson.Contents); ! ! return rJson; ! } Tuesday, 1 April 14
  13. 13. ACS/AWS 3rd Party Service API Method Stringify Reponse Minify Reponse pack JSONH homogenous collection node Mobile Function requires Data/ API Call Q Q Q Parse responseText if required UNPACK JSONH homogenous collection node API: XHR callback API: XHR HTTPRequest Node.ACS Service API Method JSON D Q Decision based on query parameters D Data response from HTTPClient API: callback API: HTTPRequest JSON / (string/min)ified D Mobile JSON Compression: HPACK using jsonh.js Mobile > Node.ACS > ACS > Mobile Ketan Majmudar Tuesday, 1 April 14

×