Skip to content

Commit

Permalink
Serialize Radio and Range with their specific attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Jan 11, 2024
1 parent e963001 commit 840da3a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/ext/gphoto2/to_json.cr
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,38 @@ module GPhoto2
end
end

class Radio
def to_json(json : JSON::Builder)
{
name: name,
label: label,
info: info.presence,
type: type.to_s,
value: value?,
choices: choices,
readonly: readonly?,
}.to_json(json)
end
end

class Range
def to_json(json : JSON::Builder)
range = self.range
{
name: name,
label: label,
info: info.presence,
type: type.to_s,
value: value?,
choices: choices,
begin: range.begin,
end: range.end,
step: step,
readonly: readonly?,
}.to_json(json)
end
end

class Window
def to_json(json : JSON::Builder)
{
Expand Down

0 comments on commit 840da3a

Please sign in to comment.