JSON.xml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="JSON" inherits="Object" version="3.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  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. The [code]indent[/code] parameter controls if and how something is indented, the string used for this parameter will be used where there should be an indent in the output, even spaces like [code]" "[/code] will work. [code]\t[/code] and [code]\n[/code] can also be used for a tab indent, or to make a newline for each indent respectively.
  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. ## JSON.print(my_dictionary, "...")
  48. {
  49. ..."name": "my_dictionary",
  50. ..."version": "1.0.0",
  51. ..."entities": [
  52. ......{
  53. ........."name": "entity_0",
  54. ........."value": "value_0"
  55. ......},
  56. ......{
  57. ........."name": "entity_1",
  58. ........."value": "value_1"
  59. ......}
  60. ...]
  61. }
  62. [/codeblock]
  63. </description>
  64. </method>
  65. </methods>
  66. <constants>
  67. </constants>
  68. </class>