Simple JSON parse/stringify for the Wren programming language

Overview

wren-json

Simple JSON parse/stringify for the Wren programming language.

  • Parses strict json and relaxed json
    • Comments
    • Unquoted keys
    • Trailing commas
  • Stringify emits strict json
  • Not 100% complete or to spec as a json parser or stringifier, nor meant to be

API

The API is all static. See test.wren for some basic examples.

Json.parse(string)

Parses a string and returns a Wren Map or List dependening on the contents. It's an error if the string is null. Parsing errors call Fiber.abort (use fiber try).

Json.parse(source_id, source_string)

Parse like above, but with a source identifier for error messages. For example the json file name.

Json.stringify(value)

Returns a string representation of the wren Map or List handed to it. Only handles Wren primitives (Bool, Num, Null, String) and List and Map, no custom types. Uses two space for indentation.

Json.stringify(value, whitespace)

Returns a string representation of the wren Map or List handed to it but with a custom whitespace. e.g if whitespace was " " it would be 4 spaces for indentation, or for example "\t" for a single tab.

Json.stringify(value, whitespace, callback)

Similar to stringify, but does NOT return a value. Instead a callback is called which is handed iterative string results. When writing json to a file or buffer, it can be a LOT more efficient to write directly, rather than allocate a huge amount of strings first and then write that instead. The callback is {|data| write(data) } (see the stringify implementation).

Extra

Running the test file

Grab wren-cli and run it:

wren-cli test.wren

notes

This code was written long ago, and was used extensively in luxe for a long while, now ported to this repo as a standalone copy.

You might also like...

Simple Math Programming Language (SMPL) for the Web

Simple Math Programming Language (SMPL) for the Web SMPL is a math-oriented programming language that can be interpreted in the browser. Its primary u

Dec 15, 2022

i18n-language.js is Simple i18n language with Vanilla Javascript

i18n-language.js i18n-language.js is Simple i18n language with Vanilla Javascript Write by Hyun SHIN Demo Page: http://i18n-language.s3-website.ap-nor

Jul 12, 2022

⚡ Extremely fast online playground for every programming language.

Riju Riju is a very fast online playground for every programming language. In less than a second, you can start playing with a Python interpreter or c

Dec 28, 2022

Programming language makes by hobby 3

Joule Programming language makes by hobby 3 About It's a compiled programming language written in JavaScript :/. Codes compile into Assembly code tha

Feb 17, 2022

VSCode extension for the rickroll-lang programming language (incomplete)

Rickroll-Lang VSCode Extension The Rick Roll programming language is a rickroll based, process oriented, dynamic, strong, esoteric programming languag

Oct 10, 2022

A Flow-based programming language for universal applications.

A Flow-based programming language for universal applications.

Hlang A Flow-based programming language for universal applications. Hlang aims to make programming easier, faster and more comfortable. It avoids codi

Dec 25, 2022

A programming language (WIP)

Umo programming language Concept Effect system (not implemented) Subtyping (not implemented) Opt-in shared mutability (not implemented) Gradual typing

Feb 25, 2022

Jaksel Script, Programming language very modern and Indonesian style

Jaksel Script Jaksel Script is a new programming language, very modern, easy to learn, using Indonesia-slang language. No programming experience requi

Jan 3, 2023

The Javascript and canvas port of MarkovJunior : A Probabilistic Programming Language.

The Javascript and canvas port of MarkovJunior : A Probabilistic Programming Language.

MarkovJunior.js MarkovJunior is a probabilistic programming language where programs are combinations of rewrite rules and inference is performed via c

Nov 15, 2022
Owner
.ruby
game/design/develop
.ruby
A minimalistic yet efficient way to stringify and revive instances via JSON.

json-instances Social Media Photo by Francisco J. Villena on Unsplash A minimalistic yet efficient way to stringify and revive instances via JSON. If

Andrea Giammarchi 11 Jun 23, 2022
Cookbook Method is the process of learning a programming language by building up a repository of small programs that implement specific programming concepts.

CookBook - Hacktoberfest Find the book you want to read next! PRESENTED BY What is CookBook? A cookbook in the programming context is collection of ti

GDSC-NITH 16 Nov 17, 2022
Write "hello world" in your native language, code "hello world" in your favorite programming language!

Hello World, All languages! ?? ?? Write "hello world" in your native language, code "hello world" in your favorite language! #hacktoberfest2022 How to

Carolina Calixto 6 Dec 13, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Find and parse the tsconfig.json file from a directory path

get-tsconfig Find and parse tsconfig.json files. Features Zero dependencies (not even TypeScript) Tested against TypeScript for accuracy Supports comm

hiroki osame 66 Jan 2, 2023
JCS (JSON Canonicalization Scheme), JSON digests, and JSON Merkle hashes

JSON Hash This package contains the following JSON utilties for Deno: digest.ts provides cryptographic hash digests of JSON trees. It guarantee that d

Hong Minhee (洪 民憙) 13 Sep 2, 2022
Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de créer un tunnel https pour c

AILI Fida Aliotti Christino 2 Mar 29, 2022