jsonx 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce7b568b144ff2599e078cf15310e3c1ff6f83a0
4
- data.tar.gz: 1981a008ac18b0cdd3cb87e1cc7a897f8f1f8671
3
+ metadata.gz: 63ea96c390df0efa7d18be5f650e055583640f2a
4
+ data.tar.gz: 1ea0569e27ab720973b8def45aaf2c0d140c5e3c
5
5
  SHA512:
6
- metadata.gz: 1599545fc5b477d1cdaa75f7323eb18b5fd5a431a53cc1906709081421ca4b68c15f14bc8a93daff5a7eccf34972a94ff50fa4268a2fe93881941f4abac7d30d
7
- data.tar.gz: 6cf9507a72efa56299735ba82f91d471faa64f7c03fb8d5f957fa543f5c28cf21a166c3d75308389b5f70d5aafc87fd096a109473b3483e7612059ce48dc42e8
6
+ metadata.gz: 98e7c839bc35f07e1752b427509a61b33cb4290884d3d9a01b73adbd2df00081ca3d6e7ec17a9aaf7775b984217fdee9088235df161deba84df5cf99117ea496
7
+ data.tar.gz: 5251ff25893aa316adeafb276b917449e3a0ad4791b0aef1a05e0ce8131396bd56db3704c0e4c35d7abe779b068fe04e82dc79c9243e012aeeb9cdee4e0c4807
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/jsonx.rb CHANGED
@@ -9,27 +9,31 @@ class JSONx
9
9
 
10
10
  attr_reader :to_s
11
11
 
12
- def initialize()
12
+ def initialize(h)
13
13
 
14
14
  types = {
15
- Hash: ->(x, k, h){
15
+ Hash: ->(k, h){
16
16
  type = 'json:object'
17
- [type, '', {name: k},
18
- *h.map {|k,v| types[v.class.to_s.to_sym].call(x, k, v)}
17
+ [type, '', (k.empty? ? {} : {name: k}),
18
+ *h.map {|k2,v| types[v.class.to_s.to_sym].call(k2, v)}
19
19
  ]
20
20
  },
21
- Fixnum: ->(x, k, n){ ['json:number', n, {name: k}]},
22
- NilClass: ->(x, k, n){ ['json:null', '', {name: k}]},
23
- String: ->(x, k, s){ ['json:string', s, {name: k}]},
24
- Array: ->(x, k, a){
21
+ Fixnum: ->(k, n){ ['json:number', n, k.empty? ? {} : {name: k}]},
22
+ NilClass: ->(k, n){ ['json:null', '', k.empty? ? {} : {name: k}]},
23
+ String: ->(k, s){ ['json:string', s, k.empty? ? {} : {name: k}]},
24
+ Array: ->(k, a){
25
+ puts 'array :' + a.inspect
25
26
  ['json:array', '', {name: k},
26
- *a.map{|y| p y; types[y.class.to_s.to_sym].call(x, k, y)}
27
+ *a.map{|y| p y; types[y.class.to_s.to_sym].call('', y.to_s)}
27
28
  ]
28
29
  }
29
30
  }
30
31
 
31
- a = types[:Hash].call xml, '', h
32
- @to_s Rexle.new(a).xml pretty: true
32
+ a = types[:Hash].call '', h
33
+ a[2] = {'xsi:schemaLocation' => "http://www.datapower.com/schemas/json jsonx.xsd",
34
+ 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
35
+ 'xmlns:json' => "http://www.ibm.com/xmlns/prod/2009/jsonx"}
36
+ @to_s = Rexle.new(a).xml pretty: true
33
37
  end
34
38
 
35
39
  end
@@ -38,4 +42,4 @@ if __FILE__ == $0 then
38
42
 
39
43
  JSONx.new(ARGV[0]).to_s
40
44
 
41
- end
45
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file