linvi / tweetinvi

Tweetinvi, an intuitive Twitter C# library for the REST and Stream API. It supports .NET, .NETCore, UAP (Xamarin)...
MIT License
1.01k stars 220 forks source link

Obtain original JSON representation of tweets and other objects #803

Open guivo opened 5 years ago

guivo commented 5 years ago

Is there any way to obtain json using the original representation of the twitter objects?

Using, as example, the tweet.ToJson() method, returns a structure that is very close to the original one but with some important differences, just two example: created_at format is ISO and not UTC, lang is an integer, encoded according an internal enumeration and not a string.

Having the possibility of obtaining the original RAW format would had flexibility to my code and increase the possibility to connect with data collected with other libraries.

linvi commented 5 years ago

This question has been debated multiple times.

The conclusion was the following:

If you want to get json object you should use the Json static objects to perform the requests. You can then transform this json using JsonConvert as explained here.

The reason to not provide the json inside the objects is about memory consumptions. Most people do not care about the json itself.

Though I think we can improve the .ToJson() logic to provide closer results to what is being sent by Twitter.

Finally, static Json classes do not always contain ALL the methods. If you need one that is not already available, feel free to open an issue and this will be added.

Cheers, Linvi

guivo commented 5 years ago

I have some code that I used locally to patch the JSON, however I will need some time and/or guidance to check how this can go in the library.