@@ -743,7 +743,7 @@ JsonInit(Json *json)
743743 json -> root .ops -> init (& json -> root , json -> obj .value );
744744}
745745
746- static Json *
746+ Json *
747747JsonExpand (Json * tmp , Datum value , bool freeValue , JsonContainerOps * ops )
748748{
749749 Json * json ;
@@ -799,7 +799,8 @@ JsonExpandDatum(Datum value, JsonContainerOps *ops, Json *tmp)
799799Json *
800800DatumGetJson (Datum value , JsonContainerOps * ops , Json * tmp )
801801{
802- Json * json = JsonExpandDatum (value , ops , tmp );
802+ Json * json = JsonExpandDatum (value , ops , tmp );
803+
803804 JsonInit (json );
804805
805806 return json ;
@@ -832,17 +833,21 @@ JsonValueToJson(JsonValue *val)
832833{
833834 if (val -> type == jbvBinary )
834835 {
835- JsonContainer * jc = val -> val .binary .data ;
836- Json * json = JsonExpand (NULL , PointerGetDatum (NULL ), false,
837- jc -> ops );
836+ JsonContainer * jc = val -> val .binary .data ;
837+ Json * json = JsonExpand (NULL , PointerGetDatum (NULL ), false,
838+ jc -> ops );
839+
838840 json -> root = * jc ;
841+
839842 return json ;
840843 }
841844 else
842845 {
843- Json * json = JsonExpand (NULL , PointerGetDatum (NULL ), false,
844- & jsonvContainerOps );
846+ Json * json = JsonExpand (NULL , PointerGetDatum (NULL ), false,
847+ & jsonvContainerOps );
848+
845849 jsonvInitContainer (& json -> root , val );
850+
846851 return json ;
847852 }
848853}
0 commit comments