|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbobik.BobikHelper
public class BobikHelper
A collection of recurring and useful utility functions
Constructor Summary | |
---|---|
BobikHelper()
|
Method Summary | |
---|---|
static java.util.List<JSONObject> |
transpose(JSONObject x)
Takes a hash of parallel arrays and turns it into a list of hashes, each having all keys from the original hash. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BobikHelper()
Method Detail |
---|
public static java.util.List<JSONObject> transpose(JSONObject x) throws java.lang.ArrayIndexOutOfBoundsException, JSONException
{'title':['A', 'B', 'C'], 'price':[4,2,5]}
becomes
[{'price':4, 'title':'A'} , {'price':2, 'title':'B'}, {'price':5, 'title':'C'}]
If the incoming arrays have different length, then a smart selector logic applies.
Empty arrays are ignored. Non-empty arrays must all have the same length. If they don't,
then an exception is thrown.
x
- a hash of parallel arrays
java.lang.ArrayIndexOutOfBoundsException
- if arrays are not of equal length
JSONException
- if the incoming object is not of the expected format
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |