JSON to S-Expressions
gist.github.com
external-link
JSON to S-Expressions. GitHub Gist: instantly share code, notes, and snippets.

Consider this: it’s much easier to parse S-Expressions than JSON! Plus, in statically typed languages, this script could excel, because it declares the type first. Remember that you can always use my S-Expression parser in C to parse them:

https://gist.github.com/Chubek/d2f0ac9067521716d2ab31c93948e885

PS: Is it just me, or ‘JSON to Sexp’ sounds like ‘Jason 2: Sex Pest’?

Is an s expression easier to parse? Maybe if you have to do it from scratch and you only have minimal memory capacity, like how it used to be when lisp was first designed.

Those aren’t real issues now, we can easily transfer data in objects and use a convenient json parsen to parse it without worrying too much about memory usage.

Sexp parser: looks for open and closed parens

Json parser: looks for delimiters, separators, keys, and values

Maybe it’s slightly more efficient and so can make sense at scale?

Feedback:

Format your README better. And don’t be a condescending jerk and say “wikipedia is your friend”. If you can’t explain what you’re doing here we’re going to question your solution. You don’t have to write a white paper, but enough to show you actually understand the concept enough to explain it in brief then you provide links to detailed refefences.

Comment your code. Meaningful names are great, but you should be explaining complex concepts and algorithms within your code. This provides clear intent to people using and maintaining your code if implemented directly.

I’m not sure I agree that a readme needs to explain what s expressions are.

If I wrote a json parser and wouldn’t explain what json was in the readme.

I do agree that a link would be better than telling people to go to Wikipedia though.

@Faresh@lemmy.ml
link
fedilink
English
2
edit-2
7M

I wrote this after I learned about attempts to use Scheme as the lingua franca of Web in the early 90s. Someone told me S-Expressions are bascilly XML and well, he’s right.

https://lemmy.ml/comment/8713988

Was it this exchange? :D

Yeah!

Create a post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



  • 1 user online
  • 1 user / day
  • 1 user / week
  • 1 user / month
  • 1.11K users / 6 months
  • 1 subscriber
  • 1.21K Posts
  • 17.8K Comments
  • Modlog