X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2FCommodsWeb.pm;h=5f85511f5fed815f2d73e70e435c710a383e2daa;hb=efc8497c2414dfded724d7181e11df53b947e387;hp=0c86e6cbfe0976b20fa6e39f50c057d354486563;hpb=31e88e03ff6e24e5c744b7f3f02346221ae5bab0;p=ypp-sc-tools.db-live.git diff --git a/yarrg/CommodsWeb.pm b/yarrg/CommodsWeb.pm index 0c86e6c..5f85511 100644 --- a/yarrg/CommodsWeb.pm +++ b/yarrg/CommodsWeb.pm @@ -38,6 +38,7 @@ use warnings; use DBI; use POSIX; +use JSON; use Commods; use CommodsDatabase; @@ -50,7 +51,9 @@ BEGIN { our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); - @EXPORT = qw(&dbw_connect &ocean_list $sourcebasedir); + @EXPORT = qw(&dbw_connect &ocean_list $sourcebasedir + &to_json &to_json_protecttags + &set_ctype_utf8); %EXPORT_TAGS = ( ); @EXPORT_OK = qw(); @@ -100,4 +103,11 @@ sub dbw_connect ($) { return dbr_connect($datadir, $ocean); } +sub to_json_protecttags ($) { + my ($v) = @_; + my $j= to_json($v); + $j =~ s,/,\\/,g; + return $j; +} + 1;