https://kotlinlang.org logo
#serialization
Title
# serialization
z

Zoltan Demant

11/13/2023, 8:26 AM
Ive had a few cases where a user specified JSON has "````json`" before the actual JSON content. Is it safe to assume that I can just try to remove it from the string before parsing it? 🤔
g

glureau

11/13/2023, 8:45 AM
This looks like Markdown notation, that's weird to have a server api responding markdown to be parsed 🤔 (Is this coming only from the documentation?)
z

Zoltan Demant

11/13/2023, 8:48 AM
I agree! The user specified JSON in this case is AI generated based on some other JSON (its for migrating one JSON structure into another one) and I think the AI has been taught on/with markdown for its instructions to begin with.
g

glureau

11/13/2023, 9:12 AM
wow AI generates json content? I'm afraid to have Regex soon and be forced to patch kind of random content from time to time 😬 (like url encoding/b64, ...) Would the API try to validate the Json before to send it back? (so that if content is not valid, backend can retry the AI call)
z

Zoltan Demant

11/13/2023, 9:32 AM
Oh yeah, it does a lot nowadays! Theres a new JSON mode for the AI that, I think, validates the JSON beforehand and (?) recreates it if needed, but I havent had any issues so far actually, just minor stuff like this - but I can work around it in my backend! I think for now, Ill just remove it manually.