Арсен Арутюнян <arutar@bk.ru> writes:
> StringInfo JsonObject = makeStringInfo();
> appendStringInfoString(JsonObject, "{\"ObjectName\":\"Bug Json Object\",\"Type\":227,\"Command\":88}");
> Datum Values[2];
> Values[0] = Int32GetDatum(227);
> Values[1] = CStringGetDatum(JsonObject->data);
That's certainly not going to work, because a CString datum doesn't
have the same representation as a JSON datum.
I think you could get away with using CStringGetTextDatum, relying on
the equivalent physical representations of JSON and text. But it
wouldn't be a terribly good idea IMO, partly because you'd be passing
up validity checking on the JSON string; plus you could never make
that work for JSONB. What you really should do instead is pass the
CString to JSON's input function, say
Values[1] = OidInputFunctionCall(F_JSON_IN, JsonObject->data, JSONOID, -1);
This is still cheating a bit --- it knows more than it ought to about
what to pass for typioparam --- but it's unlikely to break.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs