WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
274248
[GTK] jsc_value_new_string object returned as string
https://bugs.webkit.org/show_bug.cgi?id=274248
Summary
[GTK] jsc_value_new_string object returned as string
Jan-Michael Brummer
Reported
2024-05-16 02:15:52 PDT
Entering an js object into jsc_value_new_string and converting it to json leads to a string with leading and trailing quote. { \"test\": \"1\"} will be translated into "{ \"test\": \"1\"}" Test application: #include <json-glib/json-glib.h> #include <jsc/jsc.h> int main (int argc, char **argv) { const char *obj = "{ \"test\": \"1\"}"; JSCValue *val = jsc_value_new_string (jsc_context_new (), obj); g_print ("%s\n", jsc_value_to_json (val, 1)); return 0; }
Attachments
Add attachment
proposed patch, testcase, etc.
Michael Catanzaro
Comment 1
2024-05-16 05:08:11 PDT
OK, this is because jsc_value_new_string() creates a string, not an object. So it's correct that jsc_value_to_json() returns a string. You can get the behavior you desire by using jsc_value_new_json() instead.
Michael Catanzaro
Comment 2
2024-05-16 05:09:32 PDT
(In reply to Michael Catanzaro from
comment #1
)
> You can get the behavior you desire by using jsc_value_new_json() instead.
Sorry, it's jsc_value_new_from_json(). Then your test program will return: { "test": "1" }
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug