From 88042c79589f7452bdc2fd23c24f72dec475170d Mon Sep 17 00:00:00 2001 From: arcoRocks <33952704+arcoRocks@users.noreply.github.com> Date: Thu, 15 Feb 2018 14:33:38 +0100 Subject: [PATCH 1/2] Fix for #409 --- include/chaiscript/utility/json.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/chaiscript/utility/json.hpp b/include/chaiscript/utility/json.hpp index d7c632c6..c6988d54 100644 --- a/include/chaiscript/utility/json.hpp +++ b/include/chaiscript/utility/json.hpp @@ -392,7 +392,7 @@ class JSON bool skip = true; for( auto &p : *internal.Map ) { if( !skip ) { s += ",\n"; } - s += ( pad + "\"" + p.first + "\" : " + p.second.dump( depth + 1, tab ) ); + s += ( pad + "\"" + json_escape(p.first) + "\" : " + p.second.dump( depth + 1, tab ) ); skip = false; } s += ( "\n" + pad.erase( 0, 2 ) + "}" ) ; From 906e5e2b6f66f61794378f7a5cbc71f4022d5846 Mon Sep 17 00:00:00 2001 From: arcoRocks <33952704+arcoRocks@users.noreply.github.com> Date: Tue, 20 Feb 2018 16:13:17 +0100 Subject: [PATCH 2/2] Update json_15.chai --- unittests/json_15.chai | 1 + 1 file changed, 1 insertion(+) diff --git a/unittests/json_15.chai b/unittests/json_15.chai index 7e8ad652..e15ace05 100644 --- a/unittests/json_15.chai +++ b/unittests/json_15.chai @@ -16,3 +16,4 @@ assert_equal(to_json(from_json("null")), "null") assert_equal(from_json(to_json(["a": 5, "b": "stuff"])), ["a": 5, "b": "stuff"]) auto x = [3.5, true, false, "test", [], Vector(), Map()] assert_equal(from_json(to_json(x)), x) +assert_equal(from_json(to_json(["aa\\zz":"aa\\zz"])), ["aa\\zz": "aa\\zz"])