Method: Wiris::Serializer#serialize
- Defined in:
- lib/src-generic/Serializer.rb
#serialize(o) ⇒ Object
b : hash c : class d : Float e : reserved (float exp) f : false g : object end h : array/list/hash end i : Int j : enum (by index) k : NaN l : list m : -Inf n : null o : object p : +Inf q : inthash r : reference s : bytes (base64) t : true u : array nulls v : date w : enum x : exceptiona y : urlencoded string z : zero C : custom
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/src-generic/Serializer.rb', line 39 def serialize(o) c = Type.getClass(o) if (c == Type.resolveClass(Array).to_s) buf.add("a") v = o ucount = 0 l = v.length() for i in 0..l if (v._(i) == nil) ucount += 1 else if (ucount > 0) if (ucount == 1) buf.add("n") else buf.add("u") buf.add("" + ucount.to_s) end ucount = 0 end serialize(v._(i)) end end buf.add("h") elsif (o.is_a? Integer) if (o == 0) buf.add("z") else buf.add("i") buf.add("" + o.to_s) end else raise Exception, "Object class not implemented: "+ c end end |