#ds_map to struct conversion or read json as struct?
1 messages · Page 1 of 1 (latest)
Ideally, it's a lot better to keep the conversion as it is
ds_map -> json -> ds_map
struct -> json -> struct
(though tbh, you should be using structs anyway)
Is your initial data type a struct, or a ds_map? @lunar river
my code works with struct and theres like 1000 lines of code using it that way but im also reading json files witch returns a ds_map, so i wana convert it.
Yeah so
You're using the wrong function I presume
There's two json function sets, one for ds_maps
And one for structs
You have json_encode and json_decode
That's for ds_maps
You'd want
This function parses a JSON string and converts it into a collection of nested arrays and structs. An array is the equivalent of a JSON array and a struct is the equivalent of a JSON object.
Arguments
json: The JSON string to parse
filter_func: Â Filter function that processes each item. Don't pass a value or set this to undefined if you only want to set inhibit_string_convert. Syntax:Â function(key, value) -> new_value
inhibit_string_convert: Â Set this to true to disable converting strings into runtime references. Default value: false