gdharness 1.1.10 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -243,7 +243,7 @@ func announced_url() -> String:
243
243
  var file: FileAccess = FileAccess.open(ANNOUNCEMENT, FileAccess.READ)
244
244
  if file == null:
245
245
  return ""
246
- var said: Variant = JSON.parse_string(file.get_as_text())
246
+ var said: Variant = Read.json_or_null(file.get_as_text())
247
247
  file.close()
248
248
  if not said is Dictionary:
249
249
  return ""
@@ -481,7 +481,7 @@ func _on_reconnect_timer() -> void:
481
481
 
482
482
 
483
483
  func _handle_message(json_string: String) -> void:
484
- var parsed: Variant = JSON.parse_string(json_string)
484
+ var parsed: Variant = Read.json_or_null(json_string)
485
485
  if not parsed is Dictionary:
486
486
  push_error("[gdharness] The server sent something that is not a message: %s" % json_string)
487
487
  return
@@ -69,3 +69,16 @@ static func as_bool(value: Variant, fallback: bool = false) -> bool:
69
69
  var text: String = value
70
70
  return not text.is_empty()
71
71
  return fallback
72
+
73
+
74
+ ## [param text] read as JSON, or null when it does not parse, without printing anything.
75
+ ##
76
+ ## [method JSON.parse_string] prints an engine error for text that does not parse, and that error
77
+ ## lands in the log of whatever is running it. A caller sending the word "five" where a number was
78
+ ## wanted was refused properly, and the game's own log then held an error it never made, so its
79
+ ## verdict read `clean: false`. Text that is not JSON is an answer here, not a fault.
80
+ static func json_or_null(text: String) -> Variant:
81
+ var json: JSON = JSON.new()
82
+ if json.parse(text) != OK:
83
+ return null
84
+ return json.data
@@ -256,7 +256,7 @@ func fitted(value: Variant, type: int) -> Variant:
256
256
 
257
257
  if rebuilt is String and type != TYPE_STRING:
258
258
  var text: String = rebuilt
259
- var parsed: Variant = JSON.parse_string(text)
259
+ var parsed: Variant = Read.json_or_null(text)
260
260
  # A string that does not read as the type wanted is handed back as the string it is, so
261
261
  # whoever asked can refuse it. type_convert answers 0 for "not an index" and true for any
262
262
  # text at all, and a caller who sent a word got back a number they never sent: get_child
@@ -86,7 +86,7 @@ func _parse_json_maybe(value: Variant) -> Variant:
86
86
  if typeof(value) != TYPE_STRING:
87
87
  return value
88
88
  var text: String = value
89
- var parsed: Variant = JSON.parse_string(text)
89
+ var parsed: Variant = Read.json_or_null(text)
90
90
  if parsed == null and text != "null":
91
91
  return value
92
92
  return parsed
@@ -127,7 +127,7 @@ func _parse_properties_arg(raw_properties: Variant) -> Dictionary:
127
127
  var text: String = str(raw_properties)
128
128
  if text.strip_edges().is_empty():
129
129
  return {}
130
- var parsed: Variant = JSON.parse_string(text)
130
+ var parsed: Variant = Read.json_or_null(text)
131
131
  if typeof(parsed) == TYPE_DICTIONARY:
132
132
  return parsed
133
133
  return {}
@@ -69,3 +69,16 @@ static func as_bool(value: Variant, fallback: bool = false) -> bool:
69
69
  var text: String = value
70
70
  return not text.is_empty()
71
71
  return fallback
72
+
73
+
74
+ ## [param text] read as JSON, or null when it does not parse, without printing anything.
75
+ ##
76
+ ## [method JSON.parse_string] prints an engine error for text that does not parse, and that error
77
+ ## lands in the log of whatever is running it. A caller sending the word "five" where a number was
78
+ ## wanted was refused properly, and the game's own log then held an error it never made, so its
79
+ ## verdict read `clean: false`. Text that is not JSON is an answer here, not a fault.
80
+ static func json_or_null(text: String) -> Variant:
81
+ var json: JSON = JSON.new()
82
+ if json.parse(text) != OK:
83
+ return null
84
+ return json.data
@@ -256,7 +256,7 @@ func fitted(value: Variant, type: int) -> Variant:
256
256
 
257
257
  if rebuilt is String and type != TYPE_STRING:
258
258
  var text: String = rebuilt
259
- var parsed: Variant = JSON.parse_string(text)
259
+ var parsed: Variant = Read.json_or_null(text)
260
260
  # A string that does not read as the type wanted is handed back as the string it is, so
261
261
  # whoever asked can refuse it. type_convert answers 0 for "not an index" and true for any
262
262
  # text at all, and a caller who sent a word got back a number they never sent: get_child
@@ -645,7 +645,7 @@ static func _images_of(scene_path: String) -> Array[String]:
645
645
  text = bytes.slice(20, mini(20 + length, bytes.size())).get_string_from_utf8()
646
646
  if text.is_empty():
647
647
  return images
648
- var parsed: Variant = JSON.parse_string(text)
648
+ var parsed: Variant = Read.json_or_null(text)
649
649
  if not parsed is Dictionary:
650
650
  return images
651
651
  var document: Dictionary = parsed
@@ -69,3 +69,16 @@ static func as_bool(value: Variant, fallback: bool = false) -> bool:
69
69
  var text: String = value
70
70
  return not text.is_empty()
71
71
  return fallback
72
+
73
+
74
+ ## [param text] read as JSON, or null when it does not parse, without printing anything.
75
+ ##
76
+ ## [method JSON.parse_string] prints an engine error for text that does not parse, and that error
77
+ ## lands in the log of whatever is running it. A caller sending the word "five" where a number was
78
+ ## wanted was refused properly, and the game's own log then held an error it never made, so its
79
+ ## verdict read `clean: false`. Text that is not JSON is an answer here, not a fault.
80
+ static func json_or_null(text: String) -> Variant:
81
+ var json: JSON = JSON.new()
82
+ if json.parse(text) != OK:
83
+ return null
84
+ return json.data
@@ -256,7 +256,7 @@ func fitted(value: Variant, type: int) -> Variant:
256
256
 
257
257
  if rebuilt is String and type != TYPE_STRING:
258
258
  var text: String = rebuilt
259
- var parsed: Variant = JSON.parse_string(text)
259
+ var parsed: Variant = Read.json_or_null(text)
260
260
  # A string that does not read as the type wanted is handed back as the string it is, so
261
261
  # whoever asked can refuse it. type_convert answers 0 for "not an index" and true for any
262
262
  # text at all, and a caller who sent a word got back a number they never sent: get_child
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdharness",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "mcpName": "io.github.Aureliolo/gdharness",
5
5
  "description": "A harness for driving a Godot 4 project from an agent: editor addons, a runtime bridge into the running game, an MCP server in front of them, and a CLI that installs and diagnoses the Godot side.",
6
6
  "type": "module",