I am using mssql as DB and storing all details as a json String.
Now i want to update part of a json object.
How to do that?
Below is the json Object.
{"customerName":"mohan","salesForceUrl":"erferf","notes":"ferfer","custId":"3bc5a660-c001-11e9-84a1-11b306ffa283","deleteInd":"N","createdDate":1565944718619,"lastUpdatedDate":null,"deletedDate":null,"feeds":[]}
when i want to update everything except feeds which is an array, how to do that, i am using JPA @Query for this.
@Modifying
@Query(value="update Customers set configJSON = JSON_MODIFY(configJSON, '$.customerName', 'mohan') where CustomerId = ?1", nativeQuery=true)
@Transactional
public void updateCutomer(String custId);
Customers is the table name configJSON is the column name.
JSON_MODIFY(configJSON, '$.customerName', 'mohan')is one possible approach. What's wrong with this statement?"custId"value in this JSON? And, what is your SQL Server version? Thanks.