From ec80850ca4325b6e980f282f636310deeca72960 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 8 Mar 2011 18:48:51 -0500 Subject: fix to json-escape feature names in hg json encoding --- decoder/hg_io.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'decoder') diff --git a/decoder/hg_io.cc b/decoder/hg_io.cc index 1af8261e..c1c93933 100644 --- a/decoder/hg_io.cc +++ b/decoder/hg_io.cc @@ -282,7 +282,8 @@ bool HypergraphIO::WriteToJSON(const Hypergraph& hg, bool remove_rules, ostream* if (use_fdict) { o << "\"features\":["; for (int i = 1; i < FD::NumFeats(); ++i) { - o << (i==1 ? "":",") << '"' << FD::Convert(i) << '"'; + o << (i==1 ? "":","); + JSONParser::WriteEscapedString(FD::Convert(i), &o); } o << "],"; } @@ -314,9 +315,10 @@ bool HypergraphIO::WriteToJSON(const Hypergraph& hg, bool remove_rules, ostream* if (!first) o << ','; if (use_fdict) o << (it->first - 1); - else - o << '"' << FD::Convert(it->first) << '"'; - o << ',' << it->second; + else { + JSONParser::WriteEscapedString(FD::Convert(it->first), &o); + } + o << ',' << it->second; first = false; } o << "]"; -- cgit v1.2.3