wip
This commit is contained in:
@@ -1,23 +1,25 @@
|
||||
// fn parse_playback_time(
|
||||
// json_string: String,
|
||||
// ) -> Result(PlaybackTime, ControlError) {
|
||||
// let decoder = {
|
||||
// let float_dececoder = fn(data_string) {
|
||||
// case float.parse(data_string) {
|
||||
// Error(_) -> decode.failure(0.0, "data")
|
||||
// Ok(float_value) -> decode.success(float_value)
|
||||
// }
|
||||
// }
|
||||
// use data <- decode.field(
|
||||
// "data",
|
||||
// decode.then(decode.string, float_dececoder),
|
||||
// )
|
||||
import gleam/dynamic/decode
|
||||
import gleam/float
|
||||
import gleam/json
|
||||
import gleam/string
|
||||
|
||||
// decode.success(PlaybackTime(data))
|
||||
// }
|
||||
pub fn parse_playback_time(
|
||||
json_string: String,
|
||||
) -> Result(Float, json.DecodeError) {
|
||||
let decoder = {
|
||||
let float_dececoder = fn(data_string) {
|
||||
case float.parse(data_string) {
|
||||
Error(_) -> decode.failure(0.0, "data")
|
||||
Ok(float_value) -> decode.success(float_value)
|
||||
}
|
||||
}
|
||||
use data <- decode.field(
|
||||
"data",
|
||||
decode.then(decode.string, float_dececoder),
|
||||
)
|
||||
|
||||
// result.map_error(
|
||||
// json.parse(from: string.trim(json_string), using: decoder),
|
||||
// fn(r) { ControlError(string.inspect(r)) },
|
||||
// )
|
||||
// }
|
||||
decode.success(data)
|
||||
}
|
||||
|
||||
json.parse(from: string.trim(json_string), using: decoder)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user