Skip to content

Integrate yyjson for automatic JSON handling in webview - #1

Open
ysdragon wants to merge 10 commits into
mainfrom
dev
Open

Integrate yyjson for automatic JSON handling in webview#1
ysdragon wants to merge 10 commits into
mainfrom
dev

Conversation

@ysdragon

Copy link
Copy Markdown
Owner

No description provided.

ysdragon and others added 10 commits August 17, 2026 06:55
Add yyjson as a Git submodule under src/c_src/yyjson.
Decode incoming webview bind request JSON into a Ring list before
invoking the Ring callback, and serialize list, number, or string
return values to JSON when calling webview_return.

BREAKING CHANGE: webview bind callbacks now receive a decoded Ring
list instead of the raw JSON request string.
Disable yyjson tests, fuzzer, docs, and install targets, add the
subdirectory excluded from all, and link yyjson privately to
ring_webview.
Update WebView documentation to explain the bound Ring function
signature, automatic JSON decoding of call arguments, and how
`wreturn()` resolves JavaScript promises with Ring lists, numbers,
or raw JSON strings.
Update the reference and usage guide so bound callbacks are shown
receiving a decoded Ring list in `req`. Remove the manual JSON parse
examples and clarify that `wreturn()` can take Ring lists, numbers,
or raw JSON strings when resolving JavaScript promises.
The C backend now decodes the JS request payload into a Ring list and
encodes wreturn() list/number arguments to JSON automatically, so the
examples no longer need simplejson for the webview data path.

BREAKING CHANGE: bound Ring functions receive `req` as a decoded Ring
list instead of a raw JSON string, and wreturn() encodes list/number
arguments itself. Code calling json_decode(req) must drop the decode.

- req arrives as a decoded Ring list: drop json_decode(req) (52 sites)
  and the substr(req) bracket-stripping hacks (23, 42, 43)
- wreturn() accepts lists/numbers directly: drop json_encode() wrappers
  (48 sites); split buildStateJSON()/build_notes_json() helpers so they
  return Ring lists, keeping json_encode only at their evalJS/file-write
  callers
- remove load "simplejson.ring" from 19 files with no remaining JSON use;
  keep it where examples parse curl/HTTP responses, persist state to
  files, embed JSON in evalJS, or decode double-encoded JS payloads
- 04_callbacks: print req with see (string + list is a runtime error)
- 37_weather_app: switch from OpenWeatherMap (dead demo key) to
  Open-Meteo (free, no key); geocode city via Open-Meteo geocoding API,
  map WMO weather codes to descriptions/icons, reshape responses to the
  existing frontend structure
Add src/c_src/ring_webview_json.h to the files list in package.ring so
the JSON bridge header is distributed with the package and available to
the webview C build.
Move the yyjson subdirectory setup ahead of the webview target
configuration and force position-independent code so the vendored
library can link into the shared webview extension without relocation
errors.
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.

1 participant