JSONParseResult.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="JSONParseResult" inherits="Reference" category="Core" version="3.0.alpha.custom_build">
  3. <brief_description>
  4. Data class wrapper for decoded JSON.
  5. </brief_description>
  6. <description>
  7. Returned by [method JSON.parse], [code]JSONParseResult[/code] contains decoded JSON or error information if JSON source not successfully parsed. You can check if JSON source was successfully parsed with [code]if json_result.error == 0[/code].
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <demos>
  12. </demos>
  13. <methods>
  14. <method name="get_error" qualifiers="const">
  15. <return type="int" enum="Error">
  16. </return>
  17. <description>
  18. </description>
  19. </method>
  20. <method name="get_error_line" qualifiers="const">
  21. <return type="int">
  22. </return>
  23. <description>
  24. </description>
  25. </method>
  26. <method name="get_error_string" qualifiers="const">
  27. <return type="String">
  28. </return>
  29. <description>
  30. </description>
  31. </method>
  32. <method name="get_result" qualifiers="const">
  33. <return type="Variant">
  34. </return>
  35. <description>
  36. </description>
  37. </method>
  38. <method name="set_error">
  39. <return type="void">
  40. </return>
  41. <argument index="0" name="error" type="int" enum="Error">
  42. </argument>
  43. <description>
  44. </description>
  45. </method>
  46. <method name="set_error_line">
  47. <return type="void">
  48. </return>
  49. <argument index="0" name="error_line" type="int">
  50. </argument>
  51. <description>
  52. </description>
  53. </method>
  54. <method name="set_error_string">
  55. <return type="void">
  56. </return>
  57. <argument index="0" name="error_string" type="String">
  58. </argument>
  59. <description>
  60. </description>
  61. </method>
  62. <method name="set_result">
  63. <return type="void">
  64. </return>
  65. <argument index="0" name="result" type="Variant">
  66. </argument>
  67. <description>
  68. </description>
  69. </method>
  70. </methods>
  71. <members>
  72. <member name="error" type="int" setter="set_error" getter="get_error" enum="Error">
  73. The error type if JSON source was not successfully parsed. See [@Global Scope]ERR_* constants.
  74. </member>
  75. <member name="error_line" type="int" setter="set_error_line" getter="get_error_line">
  76. The line number where the error occurred if JSON source was not successfully parsed.
  77. </member>
  78. <member name="error_string" type="String" setter="set_error_string" getter="get_error_string">
  79. The error message if JSON source was not successfully parsed. See [@Global Scope]ERR_* constants.
  80. </member>
  81. <member name="result" type="Variant" setter="set_result" getter="get_result">
  82. A [Variant] containing the parsed JSON. Use typeof() to check if it is what you expect. For example, if JSON source starts with braces [code]{}[/code] a [Dictionary] will be returned, if JSON source starts with array braces [code][][/code] an [Array] will be returned.
  83. [i]Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert all numerical values to float types.[/i]
  84. [codeblock]
  85. p = JSON.parse('["hello", "world", "!"]')
  86. if typeof(p) == TYPE_ARRAY:
  87. print(p[0]) # prints 'hello'
  88. else:
  89. print("unexpected results")
  90. [/codeblock]
  91. </member>
  92. </members>
  93. <constants>
  94. </constants>
  95. </class>