def write_json_char(ch)
      # This table describes the handling for the first 0x30 characters
      # 0 : escape using "\u00xx" notation
      # 1 : just output index
      # <other> : escape using "\<other>" notation
      kJSONCharTable = [
          # 0 1 2 3 4 5 6 7 8 9 A B C D E F
          0, 0, 0, 0, 0, 0, 0, 0,'b','t','n', 0,'f','r', 0, 0, # 0
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 1
          1, 1,'"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 2
      ]

      ch_value = ch[0]
      if (ch_value.kind_of? String)
        ch_value = ch.bytes.first
      end
      if (ch_value >= 0x30)
        if (ch == @@kJSONBackslash) # Only special character >= 0x30 is '\'
          trans.write(@@kJSONBackslash)
          trans.write(@@kJSONBackslash)
        else
          trans.write(ch)
        end
      else
        outCh = kJSONCharTable[ch_value];
        # Check if regular character, backslash escaped, or JSON escaped
        if outCh.kind_of? String
          trans.write(@@kJSONBackslash)
          trans.write(outCh)
        elsif outCh == 1
          trans.write(ch)
        else
          write_json_escape_char(ch)
        end
      end
    end
def write_json_char(ch)
      # This table describes the handling for the first 0x30 characters
      # 0 : escape using "\u00xx" notation
      # 1 : just output index
      # <other> : escape using "\<other>" notation
      kJSONCharTable = [
          # 0 1 2 3 4 5 6 7 8 9 A B C D E F
          0, 0, 0, 0, 0, 0, 0, 0,'b','t','n', 0,'f','r', 0, 0, # 0
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 1
          1, 1,'"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 2
      ]

      ch_value = ch[0]
      if (ch_value.kind_of? String)
        ch_value = ch.bytes.first
      end
      if (ch_value >= 0x30)
        if (ch == @@kJSONBackslash) # Only special character >= 0x30 is '\'
          trans.write(@@kJSONBackslash)
          trans.write(@@kJSONBackslash)
        else
          trans.write(ch)
        end
      else
        outCh = kJSONCharTable[ch_value];
        # Check if regular character, backslash escaped, or JSON escaped
        if outCh.kind_of? String
          trans.write(@@kJSONBackslash)
          trans.write(outCh)
        elsif outCh == 1
          trans.write(ch)
        else
          write_json_escape_char(ch)
        end
      end
    end
Write the character ch as part of a JSON string, escaping as appropriate.