summaryrefslogtreecommitdiff
path: root/json.h
diff options
context:
space:
mode:
authorJoey Adams2010-08-04 21:44:22 +0000
committerJoey Adams2010-08-04 21:44:22 +0000
commit2b2fda2b7219004d65c1d121e7fed52ba85a9fb8 (patch)
tree30300ad44b786a6d5ed6106f1010c481d49b6e10 /json.h
parentf475e581b72b8c42cf951f6653610d15e71caeee (diff)
Made JSON datatype well-behaved with respect to character sets.
Note that this is currently untested with server encodings other than UTF-8. The encoding policy used is: JSON nodes and most of the JSON functions still operate in UTF-8. Strings are converted between server encoding and UTF-8 when they go in and out of varlena (text*), and a set of helper functions are implemented to make these conversions simple to apply. It is done this way because converting individual codepoints to/from whatever the server encoding may be is nontrivial (possibly requires a loaded module). The JSON code needs to encode/decode codepoints when it deals with escapes. Although a more clever and efficient solution might be to defer charset conversions to when they're necessary (e.g. round up all the escapes and encode them all at once), this is not simple, and it's probably not much more efficient, either. Conversions to/from server encoding and UTF-8 are no-ops when the server encoding is UTF-8, anyway.
Diffstat (limited to 'json.h')
-rw-r--r--json.h4
1 files changed, 1 insertions, 3 deletions
diff --git a/json.h b/json.h
index de4fb26..588f3cb 100644
--- a/json.h
+++ b/json.h
@@ -125,6 +125,7 @@ struct json_node
bool json_validate(const char *str);
+bool json_validate_server_encoded(const char *str);
json_node *json_decode(const char *str);
#define JSONOPT_USE_ORIG 1
@@ -211,7 +212,4 @@ void json_set_string(json_node * node, const char *str, size_t length);
const char *json_get_number(json_node * node);
void json_set_number(json_node * node, const char *number, size_t length);
-/* Utility function used by json_get to automatically apply from_json to its result. */
-const char *from_json_cstring(const char *input, const char *funcname);
-
#endif