Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (27 sloc) 869 Bytes
Red [
Title: "JSON codec"
Author: "Gabriele Santilli"
File: %json.red
Purpose: "Adds JSON as a valid data type to use with LOAD/AS and SAVE/AS"
Rights: "Copyright (C) 2019 Red Foundation. All rights reserved."
License: {
Distributed under the Boost Software License, Version 1.0.
See https://github.com/red/red/blob/master/BSL-License.txt
}
]
#include %environment/codecs/json/load-json.red
#include %environment/codecs/json/to-json.red
put system/codecs 'json context [
Title: "JSON codec"
Name: 'JSON
Mime-Type: [application/json]
Suffixes: [%.json]
encode: func [data [any-type!] where [file! url! none!]] [
to-json data
]
decode: func [text [string! binary! file!]] [
if file? text [text: read text]
if binary? text [text: to string! text]
load-json text
]
]
You can’t perform that action at this time.