diff --git a/src/redisjson.rs b/src/redisjson.rs index 16a63b3..27ef66a 100644 --- a/src/redisjson.rs +++ b/src/redisjson.rs @@ -256,7 +256,7 @@ impl RedisJSON { return Ok(-1); } match serde_json::from_str(scalar)? { - Value::Array(_) | Value::Object(_) => Ok(-1), + Value::Array(_) => Ok(-1), v => { let end: usize = if end == 0 || end == -1 { // default end of array diff --git a/test/pytest/test.py b/test/pytest/test.py index 627fcc5..0fa3de3 100644 --- a/test/pytest/test.py +++ b/test/pytest/test.py @@ -469,7 +469,7 @@ def testArrIndexCommand(self): r.flushdb() self.assertOk(r.execute_command('JSON.SET', 'test', - '.', '{ "arr": [0, 1, 2, 3, 2, 1, 0] }')) + '.', '{ "arr": [0, 1, 2, 3, 2, 1, 0, {"val": 4}, {"val": 9}] }')) self.assertEqual(r.execute_command('JSON.ARRINDEX', 'test', '.arr', 0), 0) self.assertEqual(r.execute_command('JSON.ARRINDEX', 'test', '.arr', 3), 3) self.assertEqual(r.execute_command('JSON.ARRINDEX', 'test', '.arr', 4), -1) @@ -485,6 +485,7 @@ def testArrIndexCommand(self): self.assertEqual(r.execute_command('JSON.ARRINDEX', 'test', '.arr', 3), 3) self.assertEqual(r.execute_command('JSON.ARRINDEX', 'test', '.arr', 2, 3), 4) # self.assertEqual(r.execute_command('JSON.ARRINDEX', 'test', '.arr', '[4]'), -1) + self.assertEqual(r.execute_command('JSON.ARRINDEX', 'test', '.arr', "{\"val\":4}"), 7) def testArrTrimCommand(self): """Test JSON.ARRTRIM command"""