[][src]Struct gdnative::api::JSONParseResult

pub struct JSONParseResult { /* fields omitted */ }

core class JSONParseResult inherits Reference (reference counted).

Official documentation

See the documentation of this class in the Godot engine's official documentation.

Memory management

The lifetime of this object is automatically managed through reference counting.

Class hierarchy

JSONParseResult inherits methods from:

Safety

All types in the Godot API have "interior mutability" in Rust parlance. To enforce that the official thread-safety guidelines are followed, the typestate pattern is used in the Ref and TRef smart pointers, and the Instance API. The typestate Access in these types tracks whether the access is unique, shared, or exclusive to the current thread. For more information, see the type-level documentation on Ref.

Implementations

impl JSONParseResult[src]

pub fn new() -> Ref<JSONParseResult, Unique>[src]

Creates a new instance of this object.

This is a reference-counted type. The returned object is automatically managed by Ref.

pub fn error(&self) -> Result<(), GodotError>[src]

The error type if the JSON source was not successfully parsed. See the [enum Error] constants.

pub fn error_line(&self) -> i64[src]

The line number where the error occurred if the JSON source was not successfully parsed.

pub fn error_string(&self) -> GodotString[src]

The error message if the JSON source was not successfully parsed. See the [enum Error] constants.

pub fn result(&self) -> Variant[src]

A [Variant] containing the parsed JSON. Use [method @GDScript.typeof] or the [code]is[/code] keyword to check if it is what you expect. For example, if the JSON source starts with curly braces ([code]{}[/code]), a [Dictionary] will be returned. If the JSON source starts with brackets ([code][][/code]), an [Array] will be returned.
			[b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, parsing a JSON text will convert all numerical values to [float] types.
			[b]Note:[/b] JSON objects do not preserve key order like Godot dictionaries, thus, you should not rely on keys being in a certain order if a dictionary is constructed from JSON. In contrast, JSON arrays retain the order of their elements:
			[codeblock]
			var p = JSON.parse('["hello", "world", "!"]')
			if typeof(p.result) == TYPE_ARRAY:
			    print(p.result[0]) # Prints "hello"
			else:
			    push_error("Unexpected results.")
			[/codeblock]

pub fn set_error(&self, error: i64)[src]

The error type if the JSON source was not successfully parsed. See the [enum Error] constants.

pub fn set_error_line(&self, error_line: i64)[src]

The line number where the error occurred if the JSON source was not successfully parsed.

pub fn set_error_string(&self, error_string: impl Into<GodotString>)[src]

The error message if the JSON source was not successfully parsed. See the [enum Error] constants.

pub fn set_result(&self, result: impl OwnedToVariant)[src]

A [Variant] containing the parsed JSON. Use [method @GDScript.typeof] or the [code]is[/code] keyword to check if it is what you expect. For example, if the JSON source starts with curly braces ([code]{}[/code]), a [Dictionary] will be returned. If the JSON source starts with brackets ([code][][/code]), an [Array] will be returned.
			[b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, parsing a JSON text will convert all numerical values to [float] types.
			[b]Note:[/b] JSON objects do not preserve key order like Godot dictionaries, thus, you should not rely on keys being in a certain order if a dictionary is constructed from JSON. In contrast, JSON arrays retain the order of their elements:
			[codeblock]
			var p = JSON.parse('["hello", "world", "!"]')
			if typeof(p.result) == TYPE_ARRAY:
			    print(p.result[0]) # Prints "hello"
			else:
			    push_error("Unexpected results.")
			[/codeblock]

Methods from Deref<Target = Reference>

pub fn init_ref(&self) -> bool[src]

Initializes the internal reference counter. Use this only if you really know what you are doing.
				Returns whether the initialization was successful.

Trait Implementations

impl Debug for JSONParseResult[src]

impl Deref for JSONParseResult[src]

type Target = Reference

The resulting type after dereferencing.

impl DerefMut for JSONParseResult[src]

impl GodotObject for JSONParseResult[src]

type RefKind = RefCounted

The memory management kind of this type. This modifies the behavior of the Ref smart pointer. See its type-level documentation for more information. Read more

impl Instanciable for JSONParseResult[src]

impl SubClass<Object> for JSONParseResult[src]

impl SubClass<Reference> for JSONParseResult[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubClass<T> for T where
    T: GodotObject
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.