mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-10-26 08:18:26 +03:00
Fix empty JSON key parsing
This commit is contained in:
parent
15579a457b
commit
37d836388c
@ -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'
|
||||
|
@ -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
|
||||
|
||||
|
@ -16,7 +16,8 @@ def post_json():
|
||||
"spacing": "\\n",
|
||||
"g_clef": "\\uD834\\uDD1E",
|
||||
"items": [true, \"true\", 1],
|
||||
"variable": "\\\\"
|
||||
"variable": "\\\\",
|
||||
"": "empty"
|
||||
}"""
|
||||
)
|
||||
return ""
|
||||
|
@ -363,14 +363,8 @@ pub fn object_value(reader: &mut Reader) -> ParseResult<JsonValue> {
|
||||
}
|
||||
|
||||
fn key(reader: &mut Reader) -> ParseResult<Template> {
|
||||
let save = reader.state;
|
||||
let name = string_template(reader).map_err(|e| e.non_recoverable())?;
|
||||
if name.elements.is_empty() {
|
||||
let kind = ParseErrorKind::Json(JsonErrorVariant::EmptyElement);
|
||||
Err(ParseError::new(save.pos, false, kind))
|
||||
} else {
|
||||
Ok(name)
|
||||
}
|
||||
Ok(name)
|
||||
}
|
||||
|
||||
fn object_element(reader: &mut Reader) -> ParseResult<JsonObjectElement> {
|
||||
|
Loading…
Reference in New Issue
Block a user