1 ///
2 module dpq2.conv.jsonb;
3 
4 @safe:
5 
6 import vibe.data.json;
7 import dpq2.value;
8 import dpq2.oids: OidType;
9 
10 package:
11 
12 import std..string;
13 import std.conv: to;
14 
15 ///
16 Json jsonbValueToJson(in Value v)
17 {
18     assert(v.oidType == OidType.Jsonb);
19 
20     if(v.data[0] != 1)
21         throw new ValueConvException(
22             ConvExceptionType.CORRUPTED_JSONB,
23             "Unknown jsonb format byte: "~v._data[0].to!string,
24             __FILE__, __LINE__
25             );
26 
27     string s = (cast(const(char[])) v._data[1 .. $]).to!string;
28 
29     return parseJsonString(s);
30 }