0

I am building a stats table that tracks user data points. The JSON is dynamic and can grow for multiple levels. I'm basically getting an error about invalid JSON using json_merge_patch, which I have used often before. I can not figure out why this is giving me the following error:

ERROR: Invalid JSON text in argument 1 to function json_merge_patch: "Invalid value." at position 0.

insert into
    stats.daily_user_stats
  VALUES
    (null,'2022-02-02',1,18,3,'{"pageviews":{"user":1}}')
  on duplicate key update
    jdata =
      if(
        json_contains_path(jdata, 'one', '$.pageviews.user'),
        json_set(jdata, '$.pageviews.user', cast(json_extract(jdata, '$.pageviews.user')+1 as UNSIGNED)),
        json_merge_patch('jdata','{"pageviews":{"user":1}}')
      )

Any help on identifying why the JSON I'm passing to the json_merge_function is not correct?

RJW
  • 21
  • 4

1 Answers1

0

Solved. The json_merge_patch should look like this:

json_merge_patch(jdata,'{"pageviews":{"user":1}}')

RJW
  • 21
  • 4