question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Serialization (preferably through json)

See original GitHub issue

Which package is the feature request for?

discord.js

Feature

A way to serialize a reference class and rebuild it on the other side.

Ideal solution or implementation

someFunctionToPassThroughPipe(message.toJSON())
messageRecieved = discord.Message.from(data)

Alternative solutions or implementations

I could do it in my own use case, however I would rather just see it as an official feature rather than a hacky solution that could break on the next update.

Other context

This should have been implemented well before v10.x.x, just saying. It’s a rest api there is nothing critical about any of these data wrappers. Albeit makes it easier to work with in localized projects it gets more complicated when you can’t send the real thing.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kyranetcommented, Aug 10, 2022

The new package, @discordjs/structures (implemented by #8417), will implement a way to get an approximate of Discord’s raw data back in the toJSON() methods. The idea is to make discord.js use those classes and extend them to add the REST methods.

I hope that addresses your request @parmleyhunt.

0reactions
kyranetcommented, Aug 10, 2022

It’ll be approximate because 1.0 becomes 1, and 2022-08-10T14:11:23.529000+00:00 becomes 2022-08-10T14:11:23.529Z.

Other than that, the data returned by /structures is completely valid and near-identical with what Discord sends us.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serialize .Net object to json, controlled using xml attributes
I've written a small patch for Json.Net which allows the DefaultContractResolver to work with Xml attributes. It works for the simple example above,...
Read more >
Serialization - Optimizely
The Content Delivery API takes your content in the Optimizely database and converts it into JSON format, which is a format that encodes...
Read more >
Working with JSON in Apex: A Primer - David Reed
Apex can serialize and deserialize JSON to strongly-typed Apex classes and also to generic collections like Map<String, Object> and List<Object> ...
Read more >
Different Serialization Approaches for Java - Baeldung
Learn several approaches for serializing Java objects using third-party ... JSON is preferable due to readability and being schema-less.
Read more >
Serialization - Lagom Framework
Akka recommends Jackson-based serializers –preferably JSON but CBOR is also supported– as a good default in most cases. On top of Akka serializers, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found