leaving aside the evils of rowids ....
given that I have a jsonObject, and that I add a property thus:
myJson:add("rowid",rowid(table)).
I get in the json file
{ rowid: "AAAAAAAAgQE=" , ..[snip] .. }
from the data type mapping, I am surmising that this is a base-64 encoded string.
so, my question is - how to convert this back to a rowid value ? base64-decode gives me a memptr with a binary value
and, I forgot to ask, why is the mapping a base64-encoded string ? wouldn't a "number" or plain old "string" be better ?
before anyone asks .. ;)
to-rowid(<<base64-encodedString>>) gives a ?
before anyone asks .. ;)
to-rowid(<<base64-encodedString>>) gives a ?
Flag this post as spam/abuse.
also tried that. gives you a ? as well.
julian: rtfm. it is not a number because it is not an integer and isn't representable as such in the 4gl.
recall that recids /are/ represntable as integers and 4gl applications often use them more or less interchangeably.
a rowid, on the other hand is a variable-size byte array that can only sometimes be converted into an integer.
the stringified for of a rowid is /not/ a base 64 encoded value. that's why it doesn't work.
but you can do
def var s as char.
def var r as rowid.
s = string(rowid(customer)).
r = to-rowid(s).
yeah,
old habits die hard ;)
however, you can string(rowid) and to-rowid(string), so why isn't the default mapping of a rowid the stringified version ?
add("rowid",string(rowid(customer))
gives you
rowid: "0x0000000000008101"
which can be converted back into a rowid using to-rowid()
the problem that I've got is that once converted to json, I can't seem to convert it back
I may be missing the point but you should not convert is yourself but leave it to OpenEdge. Like this:
def temp-table tt no-undo
field rw as rowid.
create tt.
tt.rw = rowid(tt).
temp-table tt:handle:write-json("file","c:\temp\tt.json").
/* strange tt is not available anymore */
for each tt:
delete tt.
end.
temp-table tt:handle:read-json("file","c:\temp\tt.json").
find first tt.
message rowid(tt) eq tt.rw
view-as alert-box.
I think that you are missing the point ;)
I am constructing a json object, manually using the progress,json classes
I am not using a temp-table, so write-json is not applicable.
however, perhaps I just need to getRowid() on the inbound json object
. that may work
On 19 July 2014 10:32, Richard.Kelters
wrote:
> RE: json and rowids
> Reply by Richard.Kelters
>
> I may be missing the point but you should not convert is yourself but leave
> it to OpenEdge. Like this:
>
> def temp-table tt no-undo
>
> field rw as rowid.
>
> create tt.
>
> tt.rw = rowid(tt).
>
> temp-table tt:handle:write-json("file","c:\temp\tt.json").
>
> /* strange tt is not available anymore */
>
> for each tt:
>
> delete tt.
>
> end.
>
> temp-table tt:handle:read-json("file","c:\temp\tt.json").
>
> find first tt.
>
> message rowid(tt) eq tt.rw
>
> view-as alert-box.
>
> Stop receiving emails on this subject.
>
> Flag this post as spam/abuse.
--
Julian Lyndon-Smith
IT Director,
dot.r
http://www.dotr.com
julian:
when you say "the problem that I've got is that once converted to json, I can't seem to convert it back" how are you attempting to do it? a code snippet might give me a clue (i am quite clueless, you know).
so, it appears that I am *much* more clueless than you are ..
the answer has been staring me right in the face - there is a getRowid() method on the jsonObject .... doh ....
however, I would also like to know if it is possible to convert a string like
"AAAAAAAAAGE="
back into a rowid value ?
how did you get the string "AAAAAAAAAGE=" and what makes you think such a conversion might be possible?
string(rowid) produces hexadecimal digits, two per byte of rowid. "G" is not a hexadecimal digit.
how did you get the string "AAAAAAAAAGE=" and what makes you think such a conversion might be possible?
string(rowid) produces hexadecimal digits, two per byte of rowid. "G" is not a hexadecimal digit.
Flag this post as spam/abuse.
well, that's a pretty stupid thing to do.
Who? Me? :(
[collapse]Reply by guswell, that's a pretty stupid thing to do.
Stop receiving emails on this subject.Flag this post as spam/abuse.