diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-03-08 18:48:51 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-03-08 18:48:51 -0500 |
commit | ec80850ca4325b6e980f282f636310deeca72960 (patch) | |
tree | 6b8a5ca5722413310b6a916b82ceb91084b26f61 /decoder | |
parent | b8f64438e66e2335948492833c39dcc5afe72518 (diff) |
fix to json-escape feature names in hg json encoding
Diffstat (limited to 'decoder')
-rw-r--r-- | decoder/hg_io.cc | 10 |
1 files changed, 6 insertions, 4 deletions
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 << "]"; |