<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Marvellous</title>
    <description>The latest articles on DEV Community by Marvellous (@marvelcodes).</description>
    <link>https://dev.to/marvelcodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F459814%2F5b959a2a-1bc2-428b-8b3f-1dd416a293f5.jpeg</url>
      <title>DEV Community: Marvellous</title>
      <link>https://dev.to/marvelcodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/marvelcodes"/>
    <language>en</language>
    <item>
      <title>Converting CSV to JSON: A Quick Guide + An Online Tool</title>
      <dc:creator>Marvellous</dc:creator>
      <pubDate>Thu, 26 Sep 2024 14:19:55 +0000</pubDate>
      <link>https://dev.to/marvelcodes/converting-csv-to-json-a-quick-guide-an-online-tool-35im</link>
      <guid>https://dev.to/marvelcodes/converting-csv-to-json-a-quick-guide-an-online-tool-35im</guid>
      <description>&lt;p&gt;CSV (Comma-Separated Values) is a widely used format for storing tabular data, often seen in spreadsheets and data exchanges. While CSV is simple and effective for data storage, JSON (JavaScript Object Notation) has become the go-to format for working with structured data in web applications. Whether you're building APIs, importing/exporting data, or simply working on a JavaScript-heavy project, converting CSV to JSON is a common need.&lt;/p&gt;

&lt;p&gt;In this article, I'll walk you through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What CSV and JSON formats are&lt;/li&gt;
&lt;li&gt;Why converting CSV to JSON is important&lt;/li&gt;
&lt;li&gt;How to easily convert CSV to JSON&lt;/li&gt;
&lt;li&gt;Introducing &lt;a href="https://csvtojson.marvellous.codes/" rel="noopener noreferrer"&gt;csvtojson.marvellous.codes&lt;/a&gt; – a free online tool I built for quick conversions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is CSV?
&lt;/h2&gt;

&lt;p&gt;CSV files are plain text files that store data in rows and columns. Each line in the file represents a row, and values within the row are separated by commas. It’s a popular format for data exchange because it's simple and compatible with many tools and applications.&lt;/p&gt;

&lt;p&gt;Example of a CSV file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name, Age, Occupation
Alice, 30, Developer
Bob, 25, Designer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is JSON?
&lt;/h2&gt;

&lt;p&gt;JSON, on the other hand, is a lightweight data-interchange format that's easy to read and write for both humans and machines. It's widely used in web development for transmitting data between a server and a web application, especially in REST APIs.&lt;/p&gt;

&lt;p&gt;Example of a JSON file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Alice"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Occupation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Developer"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Bob"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Occupation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Designer"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why Convert CSV to JSON?
&lt;/h2&gt;

&lt;p&gt;While CSV is great for basic data storage and exchange, JSON is the preferred format for modern web applications because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;JavaScript Friendly&lt;/strong&gt;: JSON integrates seamlessly with JavaScript, making it easier to work with in front-end frameworks like React, Vue, and Angular.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nested Data&lt;/strong&gt;: JSON supports hierarchical and complex structures, unlike CSV which is limited to flat data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Readability&lt;/strong&gt;: JSON is often more readable and structured, which is beneficial when dealing with large datasets or APIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Methods to Convert CSV to JSON
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Manual Conversion
&lt;/h3&gt;

&lt;p&gt;For small datasets, you could manually rewrite CSV data into JSON format. However, this can be time-consuming and error-prone.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Using Code
&lt;/h3&gt;

&lt;p&gt;There are many ways to programmatically convert CSV to JSON using different languages and libraries.&lt;/p&gt;

&lt;p&gt;For instance, in JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;csv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;csvtojson&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input.csv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;jsonObj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;output.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;jsonObj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method works well for developers familiar with coding, but for non-developers or those seeking a quick, no-code solution, a web-based tool is more practical.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Using Online Tools
&lt;/h3&gt;

&lt;p&gt;For those who don't want to deal with code or install libraries, online tools provide an easy and quick solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing &lt;a href="https://csvtojson.marvellous.codes/" rel="noopener noreferrer"&gt;csvtojson.marvellous.codes&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;To simplify the CSV to JSON conversion process, I built &lt;a href="https://csvtojson.marvellous.codes/" rel="noopener noreferrer"&gt;csvtojson.marvellous.codes&lt;/a&gt;, a free and easy-to-use web tool that does the heavy lifting for you. No need to install software or write code – just upload your CSV file and download the JSON output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use csvtojson.marvellous.codes?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fast &amp;amp; Free&lt;/strong&gt;: Upload your CSV, get your JSON – simple!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Installation&lt;/strong&gt;: Access the tool from any browser without worrying about installations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open &amp;amp; Transparent&lt;/strong&gt;: The tool is straightforward, and your data isn’t stored after conversion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;For Developers and Non-Developers&lt;/strong&gt;: Whether you're a seasoned developer or someone just looking to convert a CSV file quickly, this tool fits your needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to Use It
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Visit &lt;a href="https://csvtojson.marvellous.codes/" rel="noopener noreferrer"&gt;csvtojson.marvellous.codes&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Upload your CSV file.&lt;/li&gt;
&lt;li&gt;Click "Convert".&lt;/li&gt;
&lt;li&gt;Download the JSON file generated.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It’s as simple as that!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Converting CSV to JSON is a common task in web development, especially when working with APIs and JavaScript applications. Whether you choose to use code or tools like &lt;a href="https://csvtojson.marvellous.codes/" rel="noopener noreferrer"&gt;csvtojson.marvellous.codes&lt;/a&gt;, understanding both formats is essential for modern data handling.&lt;/p&gt;

&lt;p&gt;Give the tool a try, and feel free to share any feedback. Happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>json</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to create a container component</title>
      <dc:creator>Marvellous</dc:creator>
      <pubDate>Tue, 09 Aug 2022 12:45:00 +0000</pubDate>
      <link>https://dev.to/marvelcodes/how-to-create-a-container-components-ah</link>
      <guid>https://dev.to/marvelcodes/how-to-create-a-container-components-ah</guid>
      <description>&lt;p&gt;Need to create a component that can take in other components/elements as children or just a component that wraps your app? Well you're in luck, here's a short tutorial on how to do it.&lt;/p&gt;

&lt;p&gt;A really straight to the point answer is having your component have a prop with a type &lt;code&gt;JSX.Element&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Card = ({ children }: { children: JSX.Element }) =&amp;gt; {
  return (
     &amp;lt;div&amp;gt;
       { children }
     &amp;lt;/div&amp;gt;
  );
};

export default function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Hello CodeSandbox&amp;lt;/h1&amp;gt;
      &amp;lt;h2&amp;gt;Start editing to see some magic happen!&amp;lt;/h2&amp;gt;

      &amp;lt;Card&amp;gt;
        &amp;lt;h2&amp;gt;This Component can take children&amp;lt;/h2&amp;gt;
        &amp;lt;h2&amp;gt;This Component can take children&amp;lt;/h2&amp;gt;
        &amp;lt;h2&amp;gt;This Component can take children&amp;lt;/h2&amp;gt;
        &amp;lt;h2&amp;gt;This Component can take children&amp;lt;/h2&amp;gt;
        &amp;lt;h2&amp;gt;This Component can take children&amp;lt;/h2&amp;gt;
        &amp;lt;h2&amp;gt;This Component can take children&amp;lt;/h2&amp;gt;
        &amp;lt;h2&amp;gt;This Component can take children&amp;lt;/h2&amp;gt;
      &amp;lt;/Card&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>nextjs</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Fixing ClassName did not match error</title>
      <dc:creator>Marvellous</dc:creator>
      <pubDate>Wed, 09 Mar 2022 20:33:32 +0000</pubDate>
      <link>https://dev.to/marvelcodes/fixing-classname-did-not-match-error-3b8k</link>
      <guid>https://dev.to/marvelcodes/fixing-classname-did-not-match-error-3b8k</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Warning: Prop `className` did not match. Server: Client:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is probably one of the most annoying problem with Next.js, Typescript and styled-component luckily there's a work around for this.&lt;/p&gt;

&lt;p&gt;You're gonna need to install babel-plugin-styled-components&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add --dev babel-plugin-styled-components
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file named .babelrc in the root directory and configure it. Here's the config file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "presets": [
        "next/babel"
    ],
    "plugins": [
        [
            "styled-components",
            {
                "ssr": true,
                "displayName": true,
                "preprocess": false
            }
        ]
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart your server and refresh your server and you should be good. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/vercel/next.js/issues/7322" rel="noopener noreferrer"&gt;Here's the issue on Github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ciao&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>typescript</category>
      <category>styledcomponent</category>
      <category>react</category>
    </item>
    <item>
      <title>CSS StyleSheets</title>
      <dc:creator>Marvellous</dc:creator>
      <pubDate>Wed, 09 Dec 2020 14:52:03 +0000</pubDate>
      <link>https://dev.to/marvelcodes/css-stylesheets-pn9</link>
      <guid>https://dev.to/marvelcodes/css-stylesheets-pn9</guid>
      <description>&lt;p&gt;The browser has a basic style sheet that gives a default style to any document. These style sheets are named user-agent stylesheets. Some browsers use actual style sheets for this purpose, while others simulate them in code, but the end result is the same.&lt;/p&gt;

&lt;p&gt;Some browsers let users modify the user-agent stylesheet. Although some constraints on user-agent stylesheets are set by the HTML specification, browsers still have a lot of latitude: that means that significant differences exist from one browser to another. To simplify the development process, Web developers often use a CSS reset style sheet, forcing common properties values to a known state before beginning to make alterations to suit their specific needs.&lt;/p&gt;

&lt;p&gt;Author stylesheets are style sheets that define styles as part of the design of a given web page or site. The author of the page defines the styles for the document using one or more stylesheets, which define the look and feel of the website — its theme&lt;/p&gt;

&lt;p&gt;The user (or reader) of the website can choose to override styles in many browsers using a custom &lt;strong&gt;user stylesheet&lt;/strong&gt; designed to tailor the experience to the user's wishes.&lt;/p&gt;

&lt;p&gt;Learn more from &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Cascade" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>codenewbie</category>
      <category>webdev</category>
      <category>responsivecss</category>
    </item>
    <item>
      <title>HTML &amp; CSS Comments</title>
      <dc:creator>Marvellous</dc:creator>
      <pubDate>Sat, 29 Aug 2020 21:46:43 +0000</pubDate>
      <link>https://dev.to/marvelcodes/html-css-comments-3178</link>
      <guid>https://dev.to/marvelcodes/html-css-comments-3178</guid>
      <description>&lt;p&gt;Writing lots of lines of code and you're worried you might not understand your code next week?&lt;/p&gt;

&lt;p&gt;Want to make your project understandable to other programmers? &lt;/p&gt;

&lt;p&gt;Comments are the way to go about it. A comment is a programmer-readable explanation or annotation in the source code of a computer program.&lt;/p&gt;

&lt;p&gt;Comments are added to make the source code easier for humans to understand and are generally ignored by compilers and interpreters.&lt;/p&gt;

&lt;p&gt;Comments are started with a language-specific symbol &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;HTML5&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!--This is a comment --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;CSS&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* This is a comment */
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;JavaScript&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//This is a comment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use comments&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"A handy rule of thumb is: a comment should only be added to answer a question that the code can't. If you aren't confused by what a piece of code is doing, but rather why it's doing it at that moment, then a comment should be added." - &lt;a href="https://itnext.io/what-makes-a-good-code-comment-5267debd2c24" rel="noopener noreferrer"&gt;Mark Cronin&lt;/a&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Comments can be placed wherever white space is allowed within a style sheet. They can be used on a single line, or traverse multiple lines. This allows commenting inside a block of code and between a group of codes. What matters is making your code glanceable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* A one-line comment */

/*
A comment
which stretches
over several
lines
*/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Note&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The /* */ comment syntax is used for both single and multiline comments. There is no other way to specify comments in external style sheets.&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>codenewbie</category>
      <category>comments</category>
    </item>
  </channel>
</rss>
