Repository: DiceDB/dice
File: integration_tests/commands/http/json_test.go (Go)

Code before:
			},
			expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found boolean"},
		},
		{
			name: "STRLEN with no path and object at array",
			commands: []HTTPCommand{
				{Command: "JSON.SET", Body: map[string]interface{}{"key": "k", "path": "$", "json": []int{1, 2, 3, 4}}},
				{Command: "JSON.STRLEN", Body: map[string]interface{}{"key": "k"}},
			},
			expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found array"},
		},
		{
			name: "STRLEN with no path and object at number",
			commands: []HTTPCommand{
				{Command: "JSON.SET", Body: map[string]interface{}{"key": "k", "path": "$", "json": 1}},
				{Command: "JSON.STRLEN", Body: map[string]interface{}{"key": "k"}},
			},
			expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found number"},
		},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			for i, cmd := range tc.commands {
				result, _ := exec.FireCommand(cmd)

				if stringResult, ok := result.(string); ok {
					assert.Equal(t, tc.expected[i], stringResult)
				} else {
					assert.Assert(t, testutils.UnorderedEqual(tc.expected[i], result.([]interface{})))
				}
			}
		})
	}

	// Deleting the used keys
	exec.FireCommand(HTTPCommand{Command: "DEL", Body: map[string]interface{}{"key": "k"}})
}

func TestJSONMGET(t *testing.T) {
	exec := NewHTTPCommandExecutor()
	setupData := map[string]string{
		"xx":   `["hehhhe","hello"]`,
		"yy":   `{"name":"jerry","partner":{"name":"jerry","language":["rust"]},"partner2":{"language":["rust"]}}`,
		"zz":   `{"name":"tom","partner":{"name":"tom","language":["rust"]},"partner2":{"age":12,"language":["rust"]}}`,
		"doc1": `{"a":1,"b":2,"nested":{"a":3},"c":null}`,
		"doc2": `{"a":4,"b":5,"nested":{"a":6},"c":null}`,
	}

	for key, value := range setupData {
		var jsonPayload interface{}

Review comment (bug):
```suggestion
			expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found integer"},
```

Code after:
			},
			expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found boolean"},
		},
		{
			name: "STRLEN with no path and object at array",
			commands: []HTTPCommand{
				{Command: "JSON.SET", Body: map[string]interface{}{"key": "k", "path": "$", "json": []int{1, 2, 3, 4}}},
				{Command: "JSON.STRLEN", Body: map[string]interface{}{"key": "k"}},
			},
			expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found array"},
		},
		{
			name: "STRLEN with no path and object at integer",
			commands: []HTTPCommand{
				{Command: "JSON.SET", Body: map[string]interface{}{"key": "k", "path": "$", "json": 1}},
				{Command: "JSON.STRLEN", Body: map[string]interface{}{"key": "k"}},
			},
			expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found integer"},
		},
		{
			name: "STRLEN with no path and object at number",
			commands: []HTTPCommand{
				{Command: "JSON.SET", Body: map[string]interface{}{"key": "k", "path": "$", "json": 1.9}},
				{Command: "JSON.STRLEN", Body: map[string]interface{}{"key": "k"}},
			},
			expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found number"},
		},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			for i, cmd := range tc.commands {
				result, _ := exec.FireCommand(cmd)

				if stringResult, ok := result.(string); ok {
					assert.Equal(t, tc.expected[i], stringResult)
				} else {
					assert.Assert(t, testutils.UnorderedEqual(tc.expected[i], result.([]interface{})))
				}
			}
		})
	}

	// Deleting the used keys
	exec.FireCommand(HTTPCommand{Command: "DEL", Body: map[string]interface{}{"key": "k"}})
}

func TestJSONMGET(t *testing.T) {
	exec := NewHTTPCommandExecutor()
	setupData := map[string]string{
		"xx":   `["hehhhe","hello"]`,