1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Convert MessagePack format to JSON
16 module msgpack_to_json
21 if args
.has
("-h") then
22 print
"Usage: nit msgpack::msgpack_to_json [source_file.msgpack]"
23 print
"Convert MessagePack format to JSON. Read from stdin if no source_file is given."
27 var reader
= if args
.length
>= 1 then
28 new FileReader.open
(args
.first
)
31 while reader
.last_error
== null and not reader
.eof
do
32 var deserialized
= reader
.read_msgpack
34 if deserialized
!= null then
35 print deserialized
.serialize_to_json
(plain
=true, pretty
=true)