source: branches/testa-single-bookmark/rb/jsonx.rb @ 49

Last change on this file since 49 was 46, checked in by anonymous, 6 years ago

add rb directory

File size: 438 bytes
Line 
1require 'json'
2require 'pp'
3
4infname  = ARGV[0]
5#outfname = ARGV[1]
6outfname = STDOUT
7
8str = File.read(infname)
9hash = JSON.parse( str )
10
11def sortx( hash )
12  hs = {}
13
14  hash.keys.sort.map{ |key|
15    hs[key] = hash[key].sort
16  }
17  hs
18end
19
20hs = sortx( hash )
21pp JSON.pretty_generate(hs)
22
23=begin
24# pp sortx( hash )
25alist = hash.map{ | x |
26  [ [x[0]], x[1].sort]
27}
28=end
29
30
31#File.open(outfname , 'w'){|f|
32#  JSON.generate( hs , f)
33#}
34
35# pp ary
Note: See TracBrowser for help on using the repository browser.