How to serialize/deserialize a Snoowrap or Listing?
See original GitHub issueI’m using Snoowrap in a Redux application. I’d love to be able to use redux-persist, but Snoowrap’s objects are not plain-old-JavaScript-objects, so they won’t work with redux-persist. So I have two related questions:
-
Is there a way to serialize a Snoowrap constructed via
Snoowrap.fromAuthCode
so that I can reconstruct that object later on? -
The same question as (1), but with instances of
Listing
.
Right now I have to put Listing
s in my Redux store, and thus my Redux store cannot be serialized into localStorage
-friendly form. If instead of putting a Listing
in a store, I store an object that I can dynamically convert into a Listing
when (for example) I want to fetch more data, then I’d be a happy camper.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to serialize/deserialize a Snoowrap or Listing?
I'm using Snoowrap in a Redux application. I'd love to be able to use redux-persist, but Snoowrap's objects are not plain-old-JavaScript-objects, ...
Read more >How to serialize and deserialize objects on iOS
If you have a class that you want to serialize or archive, your class will need to implement the 'NSCoding' protocol. The NSCoding...
Read more >Reddit Api via Snoowrap with Nextjs + TypeScript
// types/json.ts import { Subreddit, Submission, Comment } from 'snoowrap/dist/objects'; export class Serializer<T> { serialize(inp: T): string ...
Read more >Class: snoowrap - GitHub Pages
Gets a list of all oauth scopes supported by the reddit API. Note: This lists every single oauth scope. To get the scope...
Read more >How to Serialize Deserialize List of Objects in Java? ...
Java provides a mechanism, called object serialization where an object can be represented as a sequence of bytes that includes the object's ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Currently, you can (kind of) serialize a Snoowrap, but you can’t serialize a Listing. I agree that it would be useful to have a way to do this.
(Admittedly annoying) way to serialize a snoowrap in the current version:
This issue is about serializing snoowrap instances themselves, not reddit content objects created by snoowrap.
It’s true that you can call
JSON.stringify
onListing
instances, but that won’t preserve some metadata needed to reconstruct them (e.g. the URL for fetching more items).