How would I decode and decompress this in Godot?

Hello, I am completely new to godot and the scripting language I think they call it GodotScript, and what i’m trying to do right now is basically I have this python code that encodes and compresses data and I’m trying to decode it and decompress it in GODOT but I can’t find the functionn to use?

This is the way im encoding and compressing in python

import zlib
import json
import base64

compressed_data = (base64.b64encode(zlib.compress(json_data.encode(), 9))).decode('utf-8')

And this is about how far I got in my godot script

extends Node

# Called when the node enters the scene tree for the first time.
func _ready():
	var file ="res://TurnAround.txt", FileAccess.READ)
	var content = file.get_as_text()

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):

You’d use Marshalls

Oh okay, but what functions exactly?

Well what do you need? Do you need a utf8 string? Then use base64_to_utf8, named aptly

1 Like

For compression you’d use this, it allows different compression and decompression

1 Like

Alright well, thanks for pointing me in the right direction but I was just doing some testing and it’s giving me all these I dont even know if these are errors or if it’s even doing it correctly

But at the bottom I get this?

And when I decoded it for testing purposes in python like so

compressed_data = (base64.b64encode(zlib.compress(json_data.encode(), 9))).decode('utf-8')
decoded_compressed = base64.b64decode(compressed_data)

it shows this which doesnt even match what godot had?

Then it’s not valid utf8, what are you trying to decode? Is it compressed? Then you need to decompress it first with the class I linked, using FileAccess.get_buffer