JSON.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. <argument index="0" name="json" type="String" />
  15. <description>
  16. Parses a JSON-encoded string and returns a [JSONParseResult] containing the result.
  17. </description>
  18. </method>
  19. <method name="print">
  20. <return type="String" />
  21. <argument index="0" name="value" type="Variant" />
  22. <argument index="1" name="indent" type="String" default="&quot;&quot;" />
  23. <argument index="2" name="sort_keys" type="bool" default="false" />
  24. <description>
  25. Converts a [Variant] var to JSON text and returns the result. Useful for serializing data to store or send over the network.
  26. [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.
  27. Use [code]indent[/code] parameter to pretty print the output.
  28. [b]Example output:[/b]
  29. [codeblock]
  30. ## JSON.print(my_dictionary)
  31. {"name":"my_dictionary","version":"1.0.0","entities":[{"name":"entity_0","value":"value_0"},{"name":"entity_1","value":"value_1"}]}
  32. ## JSON.print(my_dictionary, "\t")
  33. {
  34. "name": "my_dictionary",
  35. "version": "1.0.0",
  36. "entities": [
  37. {
  38. "name": "entity_0",
  39. "value": "value_0"
  40. },
  41. {
  42. "name": "entity_1",
  43. "value": "value_1"
  44. }
  45. ]
  46. }
  47. [/codeblock]
  48. </description>
  49. </method>
  50. </methods>
  51. <constants>
  52. </constants>
  53. </class>