Skip to content

Instantly share code, notes, and snippets.

@hinrik

hinrik/msg.cr Secret

Created July 21, 2018 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hinrik/af9603ec514175cd3418999066bcc0e8 to your computer and use it in GitHub Desktop.
Save hinrik/af9603ec514175cd3418999066bcc0e8 to your computer and use it in GitHub Desktop.
require "json"
class FBMessage
JSON.mapping(
sender_name: String,
timestamp_ms: Int32,
content: {type: String, default: ""},
type: String,
)
end
class FBChat
JSON.mapping(
title: String,
messages: Array(FBMessage),
)
end
json = File.open("message.json")
chat = FBChat.from_json(json)
chat.messages.reverse.each do |msg|
puts msg.sender_name
puts msg.content
exit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment