Consumer - how do I convert back to the original data?
justmark opened this issue · comments
I've got a small test running. I can send data through Faktory, and the consumer receives it fine.
If I enqueue a job with args:
vec! [1, 2, 3, 4]
I receive:
[Number(1), Number(2), Number(3), Number(4)]
That shows up with a type of &[Value]
. How do I get it back to a Vec? I've been going through serde_json docs trying to figure this out.
Thanks.
I resolved this by using:
serde_json::to_value(array)
and serde_json::from_value(job.args().to_owned()).unwrap()
If there is a better way, I'm all ears.
Hmm, yeah, this stems from the fact that unlike the other properties of a Job
, the args
field isn't public, it's only accessible through args(&self)
. Honestly, I forget why I made args
not be pub
, and looking at it now I'd be happy to accept a PR that changes the args
field from pub(crate)
to pub
.