From 37d836388c6beae9cfa3eb20d35282a7f91f3c24 Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Mon, 24 Jun 2024 21:29:40 +0200 Subject: [PATCH] Fix empty JSON key parsing --- integration/hurl/tests_ok/post_json.curl | 2 +- integration/hurl/tests_ok/post_json.hurl | 3 ++- integration/hurl/tests_ok/post_json.py | 3 ++- packages/hurl_core/src/parser/json.rs | 8 +------- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/integration/hurl/tests_ok/post_json.curl b/integration/hurl/tests_ok/post_json.curl index 79a641de8..d03f7f491 100644 --- a/integration/hurl/tests_ok/post_json.curl +++ b/integration/hurl/tests_ok/post_json.curl @@ -1,4 +1,4 @@ -curl --header 'Content-Type: application/json' --data $'{\n "name": "Bob",\n "password": "&secret\\\\\'<>",\n "age": 30,\n "strict": true,\n "spacing": "\\n",\n "g_clef": "\\uD834\\uDD1E",\n "items": [true, "true", 1],\n "variable": "\\\\"\n}' 'http://localhost:8000/post-json' +curl --header 'Content-Type: application/json' --data $'{\n "name": "Bob",\n "password": "&secret\\\\\'<>",\n "age": 30,\n "strict": true,\n "spacing": "\\n",\n "g_clef": "\\uD834\\uDD1E",\n "items": [true, "true", 1],\n "variable": "\\\\",\n "": "empty"\n}' 'http://localhost:8000/post-json' curl --header 'Content-Type: application/json' --data '[1,2,3]' 'http://localhost:8000/post-json-array' curl --header 'Content-Type: application/json' --data '[]' 'http://localhost:8000/post-json-array-empty' curl --header 'Content-Type: application/json' --data '"Hello"' 'http://localhost:8000/post-json-string' diff --git a/integration/hurl/tests_ok/post_json.hurl b/integration/hurl/tests_ok/post_json.hurl index f4bd750ba..73040c3bd 100644 --- a/integration/hurl/tests_ok/post_json.hurl +++ b/integration/hurl/tests_ok/post_json.hurl @@ -7,7 +7,8 @@ POST http://localhost:8000/post-json "spacing": "\n", "g_clef": "\uD834\uDD1E", "items": [true, "true", 1], - "variable": "{{string_variable}}" + "variable": "{{string_variable}}", + "": "empty" } HTTP 200 diff --git a/integration/hurl/tests_ok/post_json.py b/integration/hurl/tests_ok/post_json.py index c6ebe5fd2..fad3ea197 100644 --- a/integration/hurl/tests_ok/post_json.py +++ b/integration/hurl/tests_ok/post_json.py @@ -16,7 +16,8 @@ def post_json(): "spacing": "\\n", "g_clef": "\\uD834\\uDD1E", "items": [true, \"true\", 1], - "variable": "\\\\" + "variable": "\\\\", + "": "empty" }""" ) return "" diff --git a/packages/hurl_core/src/parser/json.rs b/packages/hurl_core/src/parser/json.rs index de857ad53..5e7143dd1 100644 --- a/packages/hurl_core/src/parser/json.rs +++ b/packages/hurl_core/src/parser/json.rs @@ -363,14 +363,8 @@ pub fn object_value(reader: &mut Reader) -> ParseResult { } fn key(reader: &mut Reader) -> ParseResult