1 // Written in the D programming language.
2 
3 module yajl.yajl;
4 
5 public import yajl.common;
6 public import yajl.decoder;
7 public import yajl.encoder;
8 
9 /**
10  * Short-cut for Decoder.decode.
11  */
12 T decode(T = JSONValue)(in const(char)[] json, ref Decoder.Option opt)
13 {
14     Decoder decoder = Decoder(opt);
15 
16     if (decoder.decode(json))
17         return decoder.decodedValue!T;
18 
19     throw new YajlException("Invalid json data");
20 }
21 
22 /// ditto
23 T decode(T = JSONValue)(in const(char)[] json)
24 {
25     Decoder decoder;
26 
27     if (decoder.decode(json))
28         return decoder.decodedValue!T;
29 
30     throw new YajlException("Invalid json data");
31 }
32 
33 /**
34  * Short-cut for Encoder.encode.
35  */
36 string encode(T)(auto ref T value)
37 {
38     return Encoder().encode(value);
39 }
40 
41 /// ditto
42 string encode(T)(auto ref T value, ref Encoder.Option opt)
43 {
44     return Encoder(opt).encode(value);
45 }