Sha256: 15113383587b4e3a2623f5e2d3065b4f1301036c298e0acec12faeb6a230a476
Contents?: true
Size: 842 Bytes
Versions: 11
Compression:
Stored size: 842 Bytes
Contents
#include "string_ext.h" static VALUE cString; void Init_string_ext() { cString = rb_const_get(rb_cObject, rb_intern("String")); rb_define_method(cString, "to_json", (VALUE(*)(ANYARGS)) &to_json, -1); } /** * This string should be encoded with UTF-8 (if JSON unicode support is * enabled). A call to this method returns a JSON string * encoded with UTF16 big endian characters as \u????. If * JSON.support_unicode? is false only control characters are encoded this * way, all 8-bit bytes are just passed through. */ static VALUE to_json(argc, argv, self) int argc; VALUE *argv; VALUE self; { VALUE mJSON = rb_const_get(rb_cObject, rb_intern("JSON")); VALUE json = rb_str_new2("\""); rb_str_append(json, rb_funcall(mJSON, rb_intern("utf8_to_json"), 1, self)); rb_str_append(json, rb_str_new2("\"")); return json; }
Version data entries
11 entries across 11 versions & 1 rubygems