BoxLang Quick Tips – Working with JSON

Welcome to another BoxLang quick tip – today I’m going to focus on working with JSON in BoxLang. Now, as you can probably guess, JSON is natively supported and supports what you would expect, going to and from JSON, but there’s some particularities of the support that may interest you, so I’ve dug into it. As with my other quick tips, you can skip to the video version at the bottom if you prefer. The Basics Converting data to JSON can be done two ways, either via the built in function (BIF) jsonSerialize or the member function toJSON. There’s no difference here, just use what makes sense for you: name = "Raymond"; age = 52; hobbies = ["beer","books","movies","video... more →
Posted in: JavaScript

Using JSON Schema with Google Gemini

Back about a month ago, I wrote up a post on how to generate JSON results using Google Gemini, "JSON Results with Google Gemini Generative AI API Calls". While you should read that post first, the process basically boiled down to: Setting the response type of the result to JSON. Without this, Gemini will return JSON but encoded in Markdown. Using a System Instruction to give directions on the "shape" of the JSON, i.e., use this key and that key. While these techniques work well, recently yet another feature was added that makes this even better, JSON schema support. JSON Schema is an abstract way to define the shape of JSON and can be really useful in validation. The website... more →
Posted in: JavaScript

JSON Results with Google Gemini Generative AI API Calls

Forgive the somewhat alliterative title there, but today’s post covers something that’s been on my mind since I started playing with Google Gemini, specifically, how to get the results of your API calls in JSON. To be clear, the REST API returns a result in JSON, but I’m talking about the content of the result itself. Before I continue, a quick shot out to Allen Firstenberg who has been helping me off and on with Google Gemini stuff. Anything I get wrong though is entirely my fault. 😜 Ok, so before I go on, let’s look at a typical result. Take a prompt like so: "What is the nature of light". Pass this to Gemini via the API, and the result you get, once you... more →
Posted in: JavaScript