JSON.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="JSON" inherits="Object" version="3.3">
  3. <brief_description>
  4. Helper class for parsing JSON data.
  5. </brief_description>
  6. <description>
  7. Helper class for parsing JSON data. For usage example and other important hints, see [JSONParseResult].
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="parse">
  13. <return type="JSONParseResult">
  14. </return>
  15. <argument index="0" name="json" type="String">
  16. </argument>
  17. <description>
  18. Parses a JSON-encoded string and returns a [JSONParseResult] containing the result.
  19. </description>
  20. </method>
  21. <method name="print">
  22. <return type="String">
  23. </return>
  24. <argument index="0" name="value" type="Variant">
  25. </argument>
  26. <argument index="1" name="indent" type="String" default="&quot;&quot;">
  27. </argument>
  28. <argument index="2" name="sort_keys" type="bool" default="false">
  29. </argument>
  30. <description>
  31. Converts a [Variant] var to JSON text and returns the result. Useful for serializing data to store or send over the network.
  32. [b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, converting a Variant to JSON text will convert all numerical values to [float] types.
  33. Use [code]indent[/code] parameter to pretty print the output.
  34. [b]Example output:[/b]
  35. [codeblock]
  36. ## JSON.print(my_dictionary)
  37. {"name":"my_dictionary","version":"1.0.0","entities":[{"name":"entity_0","value":"value_0"},{"name":"entity_1","value":"value_1"}]}
  38. ## JSON.print(my_dictionary, "\t")
  39. {
  40. "name": "my_dictionary",
  41. "version": "1.0.0",
  42. "entities": [
  43. {
  44. "name": "entity_0",
  45. "value": "value_0"
  46. },
  47. {
  48. "name": "entity_1",
  49. "value": "value_1"
  50. }
  51. ]
  52. }
  53. [/codeblock]
  54. </description>
  55. </method>
  56. </methods>
  57. <constants>
  58. </constants>
  59. </class>