Giter VIP home page Giter VIP logo

phel-json's Introduction

Phel-json

Phel library for converting Phel datastructures to and from JSON.

Become a Patron

Overview

This Phel library is a wrapper library around PHP json_encode and json_decode functions.

It converts Phel datastructures and basic types to a format that PHP understands before calling (php/json_encode).

It generates valid Phel datastructures (map, vector) from given JSON strings using (php/json_decode).

Installation

From the command line:

composer require mabasic/phel-json

Usage

This Phel library has two public method:

  • (json/encode value {:depth 512 :flags 0})
  • (json/decode json {:depth 512 :flags 0})
(ns your\namespace
    (:require mabasic\json\json))

(def result (json/encode {:name "Phel"  :type "lisp"}))

# result
# {"name": "Phel", "type": "lisp"}

(println (json/decode result))

# output
# {:name "Phel"  :type "Lisp"}

For developers

composer install
composer test

Sponsors & Backers

I would like to extend my thanks to the following sponsors & backers for funding my open-source journey. If you are interested in becoming a sponsor or backer, please visit the Backers page.

Contributing

Thank you for considering contributing to Phel-json! The contribution guide can be found Here.

Code of Conduct

In order to ensure that the open-source community is welcoming to all, please review and abide by the Code of Conduct.

License

Phel-json is open-source software licensed under the MIT license.

phel-json's People

Contributors

mabasic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

chemaclass

phel-json's Issues

Feedback

Here is some feedback:

  • Do you also plan to a decode method?
  • Keywords should not be encoded without a : before. You can use (php/-> keyword (getName)) to get the name of the keyword without the :
  • Symbols should be converted to a string. You can use (php/-> symbol (getName))
  • I would recommend the for loop over the foreach loop. Even better would be reduce. (reduce (fn [arr [k v]] (do (php/aset arr k v) arr)) (php/array) @{"a" 1 "b" 2})

Move phel-json library to phel-lang core

Related to phel-lang/phel-lang#59 (comment)

I thought it would be useful to create an issue in this repo to don't forget about this awesome phel-json utility, so we can have it in the phel core as json.phel and everyone can benefit from it.

The best is that you (@mabasic) are the one that create the file and the PR because it's your code, and you surely like to contribute with your name in the project too :)

But let me know if you need help anyhow to do this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.