Southclaws / pawn-json

JSON for Pawn.
MIT License
21 stars 10 forks source link

Mysql example #11

Open Gyfal opened 2 years ago

Gyfal commented 2 years ago

I would really like to store json in mysql, but here's the problem to get a value from Mysql, we need to know the length of the string ( cache_get_value_name), it is possible to somehow bypass this system or make some kind of crutch. p.s: I do not know the length that will come to me, because this is a dynamic list

TommyB123 commented 2 years ago

There's currently no way around that. The parse function needs a buffer size, otherwise it won't work. I would recommend against storing huge JSON nodes in MySQL anyway since it's not very practical with pawn. If you're only storing a small bit of extra JSON data, you should be able to figure out how big your string needs to be by creating some sample data and counting the characters.

Alternatively, you can use JSON_SaveFile and JSON_ParseFile to get around needing to know a buffer size at compile time. You'll have to redo your code to use those files rather than your existing database, though.