Jump to content

Dumb question - can json encoded things be used in all programming languages

Guest
Go to solution Solved by Gavination,

Short Answer: If I understand your question correctly, and if it's JSON, then sure. Should totally work. Think of an API that exposes REST calls and supplies JSON data. You don't care what that API was written in; what matters is the JSON payload. 

 

Long Answer: The "how" is language dependent. In C# (my go-to language), you have to de-serialize it when it comes in before working with the data and serialize it before sending it out again. Other languages may have their quirks as well, but just look for a Python JSON decoding library. It's Python, so if you're using version 2.6 or later, there is a library built-in that can handle it for you. See this: https://stackoverflow.com/questions/2331943/how-to-decode-json-with-python

Happy Hacking!

Say if I were to encode something with PHP, then decode it with Python.

 

Would that work? Thanks!

Link to comment
Share on other sites

Link to post
Share on other sites

Short Answer: If I understand your question correctly, and if it's JSON, then sure. Should totally work. Think of an API that exposes REST calls and supplies JSON data. You don't care what that API was written in; what matters is the JSON payload. 

 

Long Answer: The "how" is language dependent. In C# (my go-to language), you have to de-serialize it when it comes in before working with the data and serialize it before sending it out again. Other languages may have their quirks as well, but just look for a Python JSON decoding library. It's Python, so if you're using version 2.6 or later, there is a library built-in that can handle it for you. See this: https://stackoverflow.com/questions/2331943/how-to-decode-json-with-python

Happy Hacking!

Link to comment
Share on other sites

Link to post
Share on other sites

Don't see why not, the json format is standardized so you could write a decoder/parser in any language*if the language has no built in support for it

 

http://www.json.org/ has all you need to know to read/write json

 

* if you want to be an ass about it you could probably find some weird language with some whacky rules or limitations that would make reading json encoded files hard or impossible. In general people should stay away from words like "any".

Link to comment
Share on other sites

Link to post
Share on other sites

I've had success decoding JSON in PHP, Javascript and Python. Just not C# though. A whole load of languages have support for decoding JSON.

Speedtests

WiFi - 7ms, 22Mb down, 10Mb up

Ethernet - 6ms, 47.5Mb down, 9.7Mb up

 

Rigs

Spoiler

 Type            Desktop

 OS              Windows 10 Pro

 CPU             i5-4430S

 RAM             8GB CORSAIR XMS3 (2x4gb)

 Cooler          LC Power LC-CC-97 65W

 Motherboard     ASUS H81M-PLUS

 GPU             GeForce GTX 1060

 Storage         120GB Sandisk SSD (boot), 750GB Seagate 2.5" (storage), 500GB Seagate 2.5" SSHD (cache)

 

Spoiler

Type            Server

OS              Ubuntu 14.04 LTS

CPU             Core 2 Duo E6320

RAM             2GB Non-ECC

Motherboard     ASUS P5VD2-MX SE

Storage         RAID 1: 250GB WD Blue and Seagate Barracuda

Uses            Webserver, NAS, Mediaserver, Database Server

 

Quotes of Fame

On 8/27/2015 at 10:09 AM, Drixen said:

Linus is light years ahead a lot of other YouTubers, he isn't just an average YouTuber.. he's legitimately, legit.

On 10/11/2015 at 11:36 AM, Geralt said:

When something is worth doing, it's worth overdoing.

On 6/22/2016 at 10:05 AM, trag1c said:

It's completely blown out of proportion. Also if you're the least bit worried about data gathering then you should go live in a cave a 1000Km from the nearest establishment simply because every device and every entity gathers information these days. In the current era privacy is just fallacy and nothing more.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Yes, JSON is just text, so any language that can handle text strings can 'read' JSON. Most languages have JSON parsing libraries to make dealing with it simple too.

Link to comment
Share on other sites

Link to post
Share on other sites

Unless the language doesn't have a library for JSON, then it isn't, but even in that case one could write their own JSON parser. I personally prefer the rather obscure SDLang for most thing and XML if I need to embed data or scripts, processing instructions are pretty excellent for this application (see PHP) if not very standard.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 3 weeks later...
On 5/7/2017 at 4:33 AM, burnttoastnice said:

I've had success decoding JSON in PHP, Javascript and Python. Just not C# though. A whole load of languages have support for decoding JSON.

JSON.NET is your best friend for C#. I don't know a .NET dev that doesn't use it.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×