[json] Add deprecation warning

Change-Id: If28b66af367eea754773a7ea00eeed2f094f5ac7
Bug: 332774562
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/recipes-py/+/5414294
Reviewed-by: Chan Li <chanli@chromium.org>
Commit-Queue: Chan Li <chanli@chromium.org>
Auto-Submit: Rob Mohr <mohrr@google.com>
diff --git a/README.recipes.md b/README.recipes.md
index c71de07..e478232 100644
--- a/README.recipes.md
+++ b/README.recipes.md
@@ -2454,7 +2454,7 @@
   * cache (Path) - a path to put Go caches under.
 ### *recipe_modules* / [json](/recipe_modules/json)
 
-[DEPS](/recipe_modules/json/__init__.py#5): [raw\_io](#recipe_modules-raw_io), [step](#recipe_modules-step)
+[DEPS](/recipe_modules/json/__init__.py#5): [raw\_io](#recipe_modules-raw_io), [step](#recipe_modules-step), [warning](#recipe_modules-warning)
 
 
 Methods for producing and consuming JSON.
@@ -5505,7 +5505,7 @@
 [DEPS](/recipe_modules/json/examples/full.py#5): [json](#recipe_modules-json), [path](#recipe_modules-path), [properties](#recipe_modules-properties), [raw\_io](#recipe_modules-raw_io), [step](#recipe_modules-step)
 
 
-&mdash; **def [RunSteps](/recipe_modules/json/examples/full.py#21)(api):**
+&emsp; **@recipe_api.ignore_warnings('recipe_engine/JSON_READ_DEPRECATED')**<br>&mdash; **def [RunSteps](/recipe_modules/json/examples/full.py#21)(api):**
 ### *recipes* / [json:tests/add\_json\_log](/recipe_modules/json/tests/add_json_log.py)
 
 [DEPS](/recipe_modules/json/tests/add_json_log.py#5): [json](#recipe_modules-json), [step](#recipe_modules-step)
diff --git a/recipe.warnings b/recipe.warnings
index 248f64a..59aff7f 100644
--- a/recipe.warnings
+++ b/recipe.warnings
@@ -30,6 +30,15 @@
 }
 
 warning {
+  name: "JSON_READ_DEPRECATED"
+  description: "api.json.read() is deprecated."
+  description: ""
+  description: "Use api.file.read_json() instead."
+  deadline: "2024-06-01"
+  google_issue { host: "crbug.com" id: 332774562 }
+}
+
+warning {
   name: "PYTHON2_DEPRECATED"
   description: "Python2 is deprecated."
   description: ""
diff --git a/recipe_modules/json/__init__.py b/recipe_modules/json/__init__.py
index 22ebd37..bb909dc 100644
--- a/recipe_modules/json/__init__.py
+++ b/recipe_modules/json/__init__.py
@@ -4,5 +4,6 @@
 
 DEPS = [
   'step',
-  'raw_io'
+  'raw_io',
+  'warning',
 ]
diff --git a/recipe_modules/json/api.py b/recipe_modules/json/api.py
index 170b071..e4d60f8 100644
--- a/recipe_modules/json/api.py
+++ b/recipe_modules/json/api.py
@@ -189,6 +189,8 @@
 
     DEPRECATED: Use file.read_json instead.
     """
+    self.m.warning.issue('JSON_READ_DEPRECATED')
+
     return self.m.step(
         name, [
           'python3', '-u', self.resource('read.py'),
diff --git a/recipe_modules/json/examples/full.py b/recipe_modules/json/examples/full.py
index 5b973ae..5d0bf8e 100644
--- a/recipe_modules/json/examples/full.py
+++ b/recipe_modules/json/examples/full.py
@@ -14,10 +14,11 @@
 
 from google.protobuf import struct_pb2
 
-from recipe_engine import engine_types
+from recipe_engine import engine_types, recipe_api
 
 FULLWIDTH_Z = u'\ufeff\uff5a'
 
+@recipe_api.ignore_warnings('recipe_engine/JSON_READ_DEPRECATED')
 def RunSteps(api):
   step_result = api.step('echo1', ['echo', '[1, 2, 3]'],
       stdout=api.json.output())