SNOBOL4JSON(3)

πŸ“¦
version 2.3.1 Β· 3 versions
, in fedora 43, fedora 44, opensuse-leap 16.0

πŸ’– SNOBOL4JSON(3) πŸ’–

okay bestie, so this is the JSON Encoding and Decoding page from the CSNOBOL4 Manual, and it's literally the whole vibe for turning SNOBOL4 data into JSON and back again. let's get into it 🫢


✨ NAME ✨

JSON Encoding and Decoding β€” that's the whole job, no notes πŸ’…


πŸŽ€ SYNOPSYS πŸŽ€

(yeah it's spelled like that, we don't fix it, we respect it)

-INCLUDE 'json.sno'
      string = JSON_ENCODE(data)
      data = JSON_DECODE(string)

so you pull in json.sno with -INCLUDE, and then you've got two besties: JSON_ENCODE(data) gives you back a string, and JSON_DECODE(string) gives you back your data. iconic duo fr fr ✨


🌸 DESCRIPTION 🌸

πŸ¦‹ JSON_ENCODE(data) β€” data goes in, JSON string comes out

not every type gets an invite to this party ngl. it accepts a subset of SNOBOL4 data types:

  • STRING πŸ’œ
  • INTEGER πŸ’œ
  • REAL πŸ’œ
  • ARRAY β€” but bestie, it MUST be singly-dimensioned and zero-based. that's not a suggestion, that's the law πŸ‘‘
  • TABLE πŸ’œ

🧚 JSON_DECODE(json_string) β€” JSON string goes in, data comes out

this one accepts a proper subset of JSON, which lowkey means there are limits and omissions, and you need to know them:

  • arrays must have at least one item. an empty array? not on the menu πŸ™ˆ
  • escapes can only be used for ASCII (00-7F) characters.
  • true and false are not accepted. not me getting rejected by a parser 😭
NOTE!!! πŸ”₯ JSON is defined to use UTF-8 encoding, but this is not enforced by this library. so if you're exchanging binary data with other software that does enforce only-UTF-8 sequences, you should encode those binary strings (eg with base64) into ASCII sequences. do the conversion yourself, the library is not your babysitter πŸ’…

🌈 COMPATIBILITY 🌈

https://tools.ietf.org/html/rfc8259

that's the spec, go read it, iykyk ⭐


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’– AUTHORS πŸ’–

Philip L. Budne β€” thank you for your service, king 🫢


mwah, that's the whole page!! this was CSNOBOL4B 2.3.1, dated March 31, 2022, and you read every single bit of it β€” ate that, no crumbs, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from