We have a custom stringified object format that I'd like to explode into an object (or row?) inside of Oracle - with the goal of inserting it into a corresponding table.
The format looks like..
{key=value}:{key1=value1"}:{key2=value2}
e.g. {street=123 Main St}:{city=Somewhere}:{state=MI}:{zip=12345}
The approach I've taken in other languages generally looks like..
function packed2obj(packed_s) {
packed_s = packed_s.match(/^\{(.+)\}$/);
var packed_o = new Object();
var pieces = packed_s[1].split("}:{");
for (var i = 0; pieces != null && i < pieces.length; i++) {
match = pieces[i].match(/([^=]*)=(.*)/);
var key = new String(match[1]);
var value = new String(match[2]);
packed_o[key] = value;
}
return packed_o;
}
I found this post: pl-sql-split-string-into-an-associative-array, which was somewhat helpful, but it returns each key value pair as a separate row. I was hoping for something that might more easily inserted into a table with (mostly) matching columns (a record maybe?)
Parsing JSON into oracle sql also looks interesting, but the text isn't JSON format. It might be possible to convert it to JSON before it hits the database, but it would be more convenient to the upstream systems if we could stick with the native format.