diff --git a/Project.toml b/Project.toml index 6e3945f..d2d61e8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "NATSBridge" uuid = "f2724d33-f338-4a57-b9f8-1be882570d10" -version = "0.5.3" +version = "0.5.4" authors = ["narawat "] [deps] diff --git a/src/NATSBridge.jl b/src/NATSBridge.jl index 938971a..fd152f5 100644 --- a/src/NATSBridge.jl +++ b/src/NATSBridge.jl @@ -931,8 +931,8 @@ It handles "text" (string), "dictionary" (JSON deserialization), "arrowtable" (A 2. Converts bytes to appropriate Julia data type based on format 3. For text: converts bytes to string 4. For dictionary: converts bytes to JSON string then parses to Julia object -5. For arrowtable: reads Arrow IPC format and returns Arrow.Table -6. For jsontable: converts bytes to JSON string then parses to Vector{Dict} +5. For arrowtable: reads Arrow IPC format and returns a DataFrame +6. For jsontable: converts bytes to JSON string then parses to Vector{Dict} and return a DataFrame 7. For image/audio/video/binary: returns bytes directly # Arguments: @@ -958,11 +958,11 @@ json_data = _deserialize_data(json_bytes, "dictionary", "correlation123") # Arrow IPC data (arrowtable) arrow_bytes = Vector{UInt8}([1, 2, 3]) # Arrow IPC bytes -arrow_table = _deserialize_data(arrow_bytes, "arrowtable", "correlation123") +df = _deserialize_data(arrow_bytes, "arrowtable", "correlation123") # JSON table data (jsontable) json_table_bytes = UInt8[91, 123, 34, 105, 100, 34, 58, 49, 44, 34, 110, 97, 109, 101, 34, 58, 34, 65, 108, 105, 99, 101, 34, 125] # [{"id":1,"name":"Alice"}] -json_table = _deserialize_data(json_table_bytes, "jsontable", "correlation123") +df = _deserialize_data(json_table_bytes, "jsontable", "correlation123") ``` """ function _deserialize_data( @@ -977,11 +977,14 @@ function _deserialize_data( return JSON.parse(json_str) # Parse JSON string to JSON object elseif payload_type == "arrowtable" # Arrow table data - deserialize Arrow IPC stream io = IOBuffer(data) # Create buffer from bytes - table = Arrow.Table(io) # Read Arrow IPC format from buffer - return table # Return Arrow.Table + arrowtable = Arrow.Table(io) # Read Arrow IPC format from buffer + df = DataFrame(arrowtable) + return df elseif payload_type == "jsontable" # JSON table data - deserialize JSON json_str = String(data) # Convert bytes to string - return JSON.parse(json_str) # Parse JSON string to Vector{Dict} + jsontable = JSON.parse(json_str) # Parse JSON string to jsontable i.e. Vector{Dict} + df = DataFrame(jsontable) + return df elseif payload_type == "image" # Image data - return binary return data # Return bytes directly elseif payload_type == "audio" # Audio data - return binary