Skip to content

Conversation

@rayozzie
Copy link
Contributor

@rayozzie rayozzie commented Dec 13, 2025

The "f" is for "fun" (or perhaps for "formatted") just as it is in printf.

I have long, long wanted to implement this feature so as to dramatically reduce the number of source lines necessary to create notes (and templates) to just a few. Check it out by starting at the diffs in note.h.

Just to give you a preview...two new methods were added for the same reason that printf was added to clib: it's easier to do things in one 'format string' with multple varargs than to be forced to do a long number of operations (print, print, print, print), one item at a time, as was the case before printf.

notecard.sendRequest(JObjectf("req:hub.set product:com.blues.radnote mode:continuous"));
notecard.sendRequest(JObjectf("req:note.add body:%o file:air.qo", JObjectf("temp:%f", temp)));

The same wonderfulness can be used to add items if you prefer that style.

J *req = notecard.newRequest("hub.set");
JAddf(req, "product:com.blues.radnote mode:continuous outbound:%d sync:true", outboundMins);
notecard.sendRequest(req)

Yes, there are robust tests. No, there is no additional overhead in note-c if you don't choose to use this.

I have long, long wanted to implement this feature so as to dramatically reduce the number of source lines necessary to create notes to just a few.  Check it out by starting at the diffs in note.h.
@rayozzie rayozzie requested a review from zfields December 13, 2025 19:45
@rayozzie rayozzie changed the title feat: make it much easier to do easy things with cjson feat: make encoding JSON objects fun with cjson Dec 14, 2025
@rayozzie rayozzie changed the title feat: make encoding JSON objects fun with cjson feat: make the encoding of CJSON objects less tedious and more fun Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants