Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Shaurya
Shaurya

Posted on

     

What is the difference between parsing and serialization?

So, I've come across both terms and I don't understand how serialization is different than parsing. They seem to be different as I've never read about both in the same context but they seem to be similar as they do roughly the same thing, I think.

Top comments(4)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
ahferroin7 profile image
Austin S. Hemmelgarn
I'm a Systems Reliability and DevOps engineer for Netdata Inc. When not working, I enjoy studying linguistics and history, playing video games, and cooking all kinds of international cuisine.
  • Email
  • Location
    Ohio, United States of America
  • Work
    Site Reliability / DevOps Engineer at Netdata Incorporated
  • Joined
• Edited on• Edited

Serialization is the process of converting a data structure into a format that it can be safely stored or transmitted and the recreated from the stored or transmitted format. It's usually used to refer to applying this process to complex data structures like trees, objects, or graphs, as they don't inherently lend themselves to being transmitted as a simple string of binary data. Converting an in-memory object to JSON or XML is an example of serialization.

Parsing, on the other hand, takes a stream of (structured) data and then does something based on the contents of that stream, usually either creating an in-memory structure based on it, or executing a sequence of operations based on it. Deserialization (the reverse process of serialization) is a particular type of parsing, it takes serialized data and recreates the original data structure from it. However, you can do many other types of parsing. Compiling source code is also a type of parsing (together with then serializing the result of the parsing as machine code or assembly), as is linting or formatting code, doing static analysis of it, and many other things you would do to it using tools. So is decompressing a compressed file or listing the contents of an archive.

Note that both terms are very generic. Parsing routines and data serialization routines tend to be rather specific to the exact purpose they were designed for.

CollapseExpand
 
brandinchiu profile image
Brandin Chiu
Current CTO exploring entrepreneurship on the side; coach; mentor; instructor.Dedicated to promoting digital literacy and ideological diversity in tech.

+1 for using deserialization as a great example of parsing.

CollapseExpand
 
deciduously profile image
Ben Lovy
Just this guy, you know?
  • Email
  • Location
    Boston, MA, USA
  • Education
    Currently enrolled @ Champlain College Online
  • Work
    Rust Developer @ Tangram.dev
  • Joined
• Edited on• Edited

Parsing is the process of reading input and understanding it semantically as data structures. Serialization is the process of taking data structures and writing them to a textual format.

Deserialization is the opposite process, of taking a text format and building a data structure. The difference to parsing is that when deserializing, your data is still formatted. You expect this text format to adhere to a standard. When parsing, you are writing logic to turn one format of input into another, deserialization in my understanding is more just exchanging between alternate representations of the same data format.

CollapseExpand
 
jdforsythe profile image
Jeremy Forsythe
Self-taught dev/architect/admin of 30+ years
  • Location
    Ohio
  • Work
    Senior Software Engineer at SenSource
  • Joined

Serialization = encoding. Deserialization = decoding = parsing

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp