Socket
Book a DemoInstallSign in
Socket

csv_json_converter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv_json_converter

0.1.5
bundlerRubygems
Version published
Maintainers
1
Created
Source

CsvJsonConverter

csv_json_ - converter

:book: csv_json_convert

This gem converts a csv string to json object.

Installation

Add the following code to you Gemfile

gem 'csv_json_converter'

or install the gem on your terminal

gem install csv_json_converter

Usage

require this gem on the top of your ruby code.

Csv to json

If you want to convert csv string, to json you can use to_json method from CsvJsonConverter. Let's see how:-

For example


    require 'csv_json_converter'

    data_csv='file;text;number;hex
              test18.csv;CMkABfAGXvmSFV;9892576;jz40cbafbec8d6f92e93d22ea6ef5b'

    json_data = CsvJsonCoverter.to_json(data_csv)

    print json_data
   

The output looks like below

    { "file": "test18.csv",
      "text": "CMkABfAGXvmSFV",
      "number": 9892576,
      "hex": "jz40cbafbec8d6f92e93d22ea6ef5b"
    }

Json to csv

If you want to convert json object, to json you can use to_csv method from CsvJsonConverter. Let's see how:-

For example


    require 'csv_json_converter'

    data_json={ "file": "test18.csv",
      "text": "CMkABfAGXvmSFV",
      "number": 9892576,
      "hex": "jz40cbafbec8d6f92e93d22ea6ef5b"
    }

    csv_data = CsvJsonCoverter.to_csv(data_json)

    print csv_data
   

The output looks like below

    "file,text,number,hex\ntest18.csv,CMkABfAGXvmSFV,9892576,jz40cbafbec8d6f92e93d22ea6ef5b"

:busts_in_silhouette: Authors

:bust_in_silhouette: Pablo Zambrano

:handshake: Contributing

This repo is open for contributions. Issues, and feature requests are welcome! Feel free to check the issues page.

:star:️ Show your support

Give a star if you like this project!

(back to top)

FAQs

Package last updated on 05 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.