diff --git a/common/JSON_Tokenizer.cc b/common/JSON_Tokenizer.cc
index 608d6a0b2835debb240c353825b12af1cb58cd09..184e3dcb1269c98dcc5f92d4c7e5c90adcba7927 100644
--- a/common/JSON_Tokenizer.cc
+++ b/common/JSON_Tokenizer.cc
@@ -8,6 +8,7 @@
  * Contributors:
  *   Balasko, Jeno
  *   Baranyi, Botond
+ *   Szabo, Bence Janos
  *
  ******************************************************************************/
 
@@ -97,7 +98,7 @@ bool JSON_Tokenizer::check_for_string()
   return false;
 }
 
-bool JSON_Tokenizer::check_for_number()
+bool JSON_Tokenizer::check_for_number(bool* is_float /* = NULL */)
 {
   bool first_digit = false; // first non-zero digit reached
   bool zero = false; // first zero digit reached
@@ -156,11 +157,17 @@ bool JSON_Tokenizer::check_for_number()
       exponent_sign = true;
       break;
     default:
+      if (is_float != NULL) {
+        *is_float = decimal_point || exponent_mark;
+      }
       return first_digit || zero;
     }
     
     ++buf_pos; 
   }
+  if (is_float != NULL) {
+    *is_float = decimal_point || exponent_mark;
+  }
   return first_digit || zero;
 }
 
@@ -187,10 +194,10 @@ bool JSON_Tokenizer::check_for_separator()
 bool JSON_Tokenizer::check_for_literal(const char* p_literal)
 {
   size_t len = strlen(p_literal);
-  size_t start_pos = buf_pos;
   
   if (buf_len - buf_pos >= len && 
       0 == strncmp(buf_ptr + buf_pos, p_literal, len)) {
+    size_t start_pos = buf_pos;
     buf_pos += len;
     if (!skip_white_spaces() || check_for_separator()) {
       return true;
diff --git a/common/JSON_Tokenizer.hh b/common/JSON_Tokenizer.hh
index 2daae82a588588dcfba6a4a415a72da297e4e659..4256dc4d3119e71bf7c48fc521269182b1812735 100644
--- a/common/JSON_Tokenizer.hh
+++ b/common/JSON_Tokenizer.hh
@@ -8,6 +8,7 @@
  * Contributors:
  *   Balasko, Jeno
  *   Baranyi, Botond
+ *   Szabo, Bence Janos
  *
  ******************************************************************************/
 
@@ -86,13 +87,7 @@ private:
     * Returns true if a valid string is found before the end of the buffer
     * is reached, otherwise returns false. */
   bool check_for_string();
-  
-  /** Attempts to find a JSON number at the current buffer position.
-    * For number format see http://json.org/.
-    * Returns true if a valid number is found before the end of the buffer
-    * is reached, otherwise returns false. */
-  bool check_for_number();
-  
+
   /** Checks if the current character in the buffer is a valid JSON separator.
     * Separators are: commas (,), colons (:) and curly and square brackets ({}[]).
     * This function also steps over the separator if it's a comma.
@@ -168,6 +163,14 @@ public:
     * @param p_len [in] Length of the data in bytes */
   void put_raw_data(const char* p_data, size_t p_len);
   
+  /** Attempts to find a JSON number at the current buffer position.
+  * For number format see http://json.org/.
+  * Returns true if a valid number is found before the end of the buffer
+  * is reached, otherwise returns false.
+  * is_float variable is true if the number is a float. The result
+  * should be used only if this function returns true. */
+  bool check_for_number(bool* is_float = NULL);
+  
 }; // class JSON_Tokenizer
 
 // A dummy JSON tokenizer, use when there is no actual JSON document
diff --git a/compiler2/Identifier.cc b/compiler2/Identifier.cc
index 07a351772ac7249e598b72cc843c9e8a41097655..0c922bb1f4f413cd780285d8e76de3581b505ba3 100644
--- a/compiler2/Identifier.cc
+++ b/compiler2/Identifier.cc
@@ -656,6 +656,8 @@ namespace Common {
     {"remove__bom__", "remove_bom", "remove_bom_"},
     {"encode__base64__", "encode_base64", "encode_base64_"},
     {"decode__base64__", "decode_base64", "decode_base64_"},
+    {"json2cbor__", "json2cbor", "json2cbor_"},
+    {"cbor2json__", "cbor2json", "cbor2json_"},
     {"get__stringencoding__", "get_stringencoding", "get_stringencoding_"},
     /* reserved names of base library - keywords in ASN.1 */
     {"FALSE_", 0, "FALSE"},
diff --git a/compiler2/Value.cc b/compiler2/Value.cc
index f975e107ef534dd481e840e414ff1a3d09d7b783..7c3b1bcfa1a9bb0f1547dcc52fa27026cee5c4f8 100644
--- a/compiler2/Value.cc
+++ b/compiler2/Value.cc
@@ -183,6 +183,7 @@ namespace Common {
       case OPTYPE_BIT2INT:
       case OPTYPE_BIT2OCT:
       case OPTYPE_BIT2STR:
+      case OPTYPE_CBOR2JSON:
       case OPTYPE_CHAR2INT:
       case OPTYPE_CHAR2OCT:
       case OPTYPE_FLOAT2INT:
@@ -195,6 +196,7 @@ namespace Common {
       case OPTYPE_INT2FLOAT:
       case OPTYPE_INT2STR:
       case OPTYPE_INT2UNICHAR:
+      case OPTYPE_JSON2CBOR:
       case OPTYPE_OCT2BIT:
       case OPTYPE_OCT2CHAR:
       case OPTYPE_OCT2HEX:
@@ -523,6 +525,7 @@ namespace Common {
     case OPTYPE_BIT2INT:
     case OPTYPE_BIT2OCT:
     case OPTYPE_BIT2STR:
+    case OPTYPE_CBOR2JSON:
     case OPTYPE_CHAR2INT:
     case OPTYPE_CHAR2OCT:
     case OPTYPE_FLOAT2INT:
@@ -535,6 +538,7 @@ namespace Common {
     case OPTYPE_INT2FLOAT:
     case OPTYPE_INT2STR:
     case OPTYPE_INT2UNICHAR:
+    case OPTYPE_JSON2CBOR:
     case OPTYPE_OCT2BIT:
     case OPTYPE_OCT2CHAR:
     case OPTYPE_OCT2HEX:
@@ -914,6 +918,7 @@ namespace Common {
     case OPTYPE_BIT2INT:
     case OPTYPE_BIT2OCT:
     case OPTYPE_BIT2STR:
+    case OPTYPE_CBOR2JSON:
     case OPTYPE_CHAR2INT:
     case OPTYPE_CHAR2OCT:
     case OPTYPE_FLOAT2INT:
@@ -926,6 +931,7 @@ namespace Common {
     case OPTYPE_INT2FLOAT:
     case OPTYPE_INT2STR:
     case OPTYPE_INT2UNICHAR:
+    case OPTYPE_JSON2CBOR:
     case OPTYPE_OCT2BIT:
     case OPTYPE_OCT2CHAR:
     case OPTYPE_OCT2HEX:
@@ -1608,6 +1614,7 @@ namespace Common {
     case OPTYPE_BIT2INT:
     case OPTYPE_BIT2OCT:
     case OPTYPE_BIT2STR:
+    case OPTYPE_CBOR2JSON:
     case OPTYPE_CHAR2INT:
     case OPTYPE_CHAR2OCT:
     case OPTYPE_FLOAT2INT:
@@ -1620,6 +1627,7 @@ namespace Common {
     case OPTYPE_INT2FLOAT:
     case OPTYPE_INT2STR:
     case OPTYPE_INT2UNICHAR:
+    case OPTYPE_JSON2CBOR:
     case OPTYPE_OCT2BIT:
     case OPTYPE_OCT2CHAR:
     case OPTYPE_OCT2HEX:
@@ -1826,6 +1834,7 @@ namespace Common {
     case OPTYPE_BIT2INT:
     case OPTYPE_BIT2OCT:
     case OPTYPE_BIT2STR:
+    case OPTYPE_CBOR2JSON:
     case OPTYPE_CHAR2INT:
     case OPTYPE_CHAR2OCT:
     case OPTYPE_FLOAT2INT:
@@ -1838,6 +1847,7 @@ namespace Common {
     case OPTYPE_INT2FLOAT:
     case OPTYPE_INT2STR:
     case OPTYPE_INT2UNICHAR:
+    case OPTYPE_JSON2CBOR:
     case OPTYPE_OCT2BIT:
     case OPTYPE_OCT2CHAR:
     case OPTYPE_OCT2HEX:
@@ -2164,6 +2174,7 @@ namespace Common {
       case OPTYPE_BIT2INT:
       case OPTYPE_BIT2OCT:
       case OPTYPE_BIT2STR:
+      case OPTYPE_CBOR2JSON:
       case OPTYPE_CHAR2INT:
       case OPTYPE_CHAR2OCT:
       case OPTYPE_FLOAT2INT:
@@ -2176,6 +2187,7 @@ namespace Common {
       case OPTYPE_INT2FLOAT:
       case OPTYPE_INT2STR:
       case OPTYPE_INT2UNICHAR:
+      case OPTYPE_JSON2CBOR:
       case OPTYPE_OCT2BIT:
       case OPTYPE_OCT2CHAR:
       case OPTYPE_OCT2HEX:
@@ -3327,6 +3339,7 @@ namespace Common {
       case OPTYPE_OCT2UNICHAR:
       case OPTYPE_ENCVALUE_UNICHAR:
       case OPTYPE_ANY2UNISTR:
+      case OPTYPE_CBOR2JSON:
         return Type::T_USTR;
       case OPTYPE_INT2BIT:
       case OPTYPE_HEX2BIT:
@@ -3340,6 +3353,7 @@ namespace Common {
       case OPTYPE_STR2HEX:
         return Type::T_HSTR;
       case OPTYPE_INT2OCT:
+      case OPTYPE_JSON2CBOR:
       case OPTYPE_CHAR2OCT:
       case OPTYPE_HEX2OCT:
       case OPTYPE_BIT2OCT:
@@ -3615,6 +3629,8 @@ namespace Common {
       return "bit2oct()";
     case OPTYPE_BIT2STR:
       return "bit2str()";
+    case OPTYPE_CBOR2JSON:
+      return "cbor2json()";
     case OPTYPE_CHAR2INT:
       return "char2int()";
     case OPTYPE_CHAR2OCT:
@@ -3639,6 +3655,8 @@ namespace Common {
       return "int2str()";
     case OPTYPE_INT2UNICHAR:
       return "int2unichar()";
+    case OPTYPE_JSON2CBOR:
+      return "json2cbor()";
     case OPTYPE_OCT2BIT:
       return "oct2bit()";
     case OPTYPE_OCT2CHAR:
@@ -6708,6 +6726,7 @@ error:
       }
       break;
     case OPTYPE_OCT2BIT:
+    case OPTYPE_CBOR2JSON:
     case OPTYPE_OCT2HEX:
     case OPTYPE_OCT2STR:
       v1=u.expr.v1;
@@ -6824,6 +6843,16 @@ error:
         chk_expr_eval_value(v1, t_chk, refch, exp_val);
       }
       break;
+    case OPTYPE_JSON2CBOR: // v1
+      v1=u.expr.v1;
+      {
+        Error_Context cntxt(this, "In the operand of operation `%s'", opname);
+        v1->set_lowerid_to_ref();
+        tt1=v1->get_expr_returntype(exp_val);
+        chk_expr_operandtype_charstr(tt1, the, opname, v1);
+        chk_expr_eval_value(v1, t_chk, refch, exp_val);
+      }
+      break;
     case OPTYPE_UNICHAR2OCT: // v1 [v2]
       v1=u.expr.v1;
       {
@@ -7560,6 +7589,8 @@ error:
     case OPTYPE_CHECKSTATE_ALL:
     case OPTYPE_HOSTID:
     case OPTYPE_ISTEMPLATEKIND: // ti1 v2
+    case OPTYPE_CBOR2JSON: // v1
+    case OPTYPE_JSON2CBOR: // v1
       break;
     case OPTYPE_TESTCASENAME: { // -
       if (!my_scope) FATAL_ERROR("Value::evaluate_value()");
@@ -8862,6 +8893,8 @@ error:
       case OPTYPE_CHECKSTATE_ALL:
       case OPTYPE_HOSTID:
       case OPTYPE_ISTEMPLATEKIND: // ti1 v2
+      case OPTYPE_CBOR2JSON:
+      case OPTYPE_JSON2CBOR:
         return true;
       case OPTYPE_COMP_NULL: // -
         return false;
@@ -10095,6 +10128,7 @@ error:
     case OPTYPE_BIT2INT:
     case OPTYPE_BIT2OCT:
     case OPTYPE_BIT2STR:
+    case OPTYPE_CBOR2JSON:
     case OPTYPE_CHAR2INT:
     case OPTYPE_CHAR2OCT:
     case OPTYPE_FLOAT2INT:
@@ -10107,6 +10141,7 @@ error:
     case OPTYPE_INT2FLOAT:
     case OPTYPE_INT2STR:
     case OPTYPE_INT2UNICHAR:
+    case OPTYPE_JSON2CBOR:
     case OPTYPE_OCT2BIT:
     case OPTYPE_OCT2CHAR:
     case OPTYPE_OCT2HEX:
@@ -10471,6 +10506,7 @@ error:
     case OPTYPE_BIT2INT: // v1
     case OPTYPE_BIT2OCT: // v1
     case OPTYPE_BIT2STR: // v1
+    case OPTYPE_CBOR2JSON: // v1
     case OPTYPE_CHAR2INT: // v1
     case OPTYPE_CHAR2OCT: // v1
     case OPTYPE_FLOAT2INT: // v1
@@ -10483,6 +10519,7 @@ error:
     case OPTYPE_INT2FLOAT: // v1
     case OPTYPE_INT2STR: // v1
     case OPTYPE_INT2UNICHAR: // v1
+    case OPTYPE_JSON2CBOR: // v1
     case OPTYPE_OCT2BIT: // v1
     case OPTYPE_OCT2CHAR: // v1
     case OPTYPE_OCT2HEX: // v1
@@ -10847,6 +10884,8 @@ error:
         return create_stringRepr_predef1("bit2oct");
       case OPTYPE_BIT2STR:
         return create_stringRepr_predef1("bit2str");
+      case OPTYPE_CBOR2JSON:
+        return create_stringRepr_predef1("cbor2json");
       case OPTYPE_CHAR2INT:
         return create_stringRepr_predef1("char2int");
       case OPTYPE_CHAR2OCT:
@@ -10869,6 +10908,8 @@ error:
         return create_stringRepr_predef1("int2float");
       case OPTYPE_INT2STR:
         return create_stringRepr_predef1("int2str");
+      case OPTYPE_JSON2CBOR:
+        return create_stringRepr_predef1("json2cbor");
       case OPTYPE_INT2UNICHAR:
         return create_stringRepr_predef1("int2unichar");
       case OPTYPE_OCT2BIT:
@@ -11842,6 +11883,7 @@ error:
       case OPTYPE_BIT2INT:
       case OPTYPE_BIT2OCT:
       case OPTYPE_BIT2STR:
+      case OPTYPE_CBOR2JSON:
       case OPTYPE_CHAR2INT:
       case OPTYPE_CHAR2OCT:
       case OPTYPE_FLOAT2INT:
@@ -11854,6 +11896,7 @@ error:
       case OPTYPE_INT2FLOAT:
       case OPTYPE_INT2STR:
       case OPTYPE_INT2UNICHAR:
+      case OPTYPE_JSON2CBOR:
       case OPTYPE_OCT2BIT:
       case OPTYPE_OCT2CHAR:
       case OPTYPE_OCT2HEX:
@@ -12121,6 +12164,9 @@ error:
     case OPTYPE_BIT2STR:
       generate_code_expr_predef1(expr, "bit2str", u.expr.v1);
       break;
+    case OPTYPE_CBOR2JSON:
+      generate_code_expr_predef1(expr, "cbor2json", u.expr.v1);
+      break;  
     case OPTYPE_CHAR2INT:
       generate_code_expr_predef1(expr, "char2int", u.expr.v1);
       break;
@@ -12157,6 +12203,9 @@ error:
     case OPTYPE_INT2UNICHAR:
       generate_code_expr_predef1(expr, "int2unichar", u.expr.v1);
       break;
+    case OPTYPE_JSON2CBOR:
+      generate_code_expr_predef1(expr, "json2cbor", u.expr.v1);
+      break;  
     case OPTYPE_OCT2BIT:
       generate_code_expr_predef1(expr, "oct2bit", u.expr.v1);
       break;
@@ -14085,6 +14134,7 @@ void Value::generate_code_expr_encvalue_unichar(expression_struct *expr)
     case OPTYPE_BIT2INT:
     case OPTYPE_BIT2OCT:
     case OPTYPE_BIT2STR:
+    case OPTYPE_CBOR2JSON:
     case OPTYPE_CHAR2INT:
     case OPTYPE_CHAR2OCT:
     case OPTYPE_FLOAT2INT:
@@ -14097,6 +14147,7 @@ void Value::generate_code_expr_encvalue_unichar(expression_struct *expr)
     case OPTYPE_INT2FLOAT:
     case OPTYPE_INT2STR:
     case OPTYPE_INT2UNICHAR:
+    case OPTYPE_JSON2CBOR:
     case OPTYPE_OCT2BIT:
     case OPTYPE_OCT2CHAR:
     case OPTYPE_OCT2HEX:
diff --git a/compiler2/Value.hh b/compiler2/Value.hh
index df1e70d5c539ff582b31d7443219b5c3df2df0cf..f3fe10c0e071d51bc9a2f5fa46896a90938e8b91 100644
--- a/compiler2/Value.hh
+++ b/compiler2/Value.hh
@@ -272,6 +272,9 @@ namespace Common {
       OPTYPE_CHECKSTATE_ALL, // [r1] v2, port or all
       OPTYPE_HOSTID, // [v1]
       OPTYPE_ISTEMPLATEKIND, // ti1 v2
+      
+      OPTYPE_CBOR2JSON, // v1
+      OPTYPE_JSON2CBOR, // v1
 
       NUMBER_OF_OPTYPES // must be last
     };
diff --git a/compiler2/ttcn3/compiler.l b/compiler2/ttcn3/compiler.l
index d0d11069f36ea70fb902b63a00a34eff2d7e1e51..6f48b693383e7b6ac00fea7aab49f6cfe42982fa 100644
--- a/compiler2/ttcn3/compiler.l
+++ b/compiler2/ttcn3/compiler.l
@@ -540,6 +540,7 @@ bit2hex		RETURN(bit2hexKeyword);
 bit2int		RETURN(bit2intKeyword);
 bit2oct		RETURN(bit2octKeyword);
 bit2str		RETURN(bit2strKeyword);
+cbor2json	RETURN(cbor2JsonKeyword);
 char2int	RETURN(char2intKeyword);
 char2oct	RETURN(char2octKeyword);
 decomp		RETURN(decompKeyword);
@@ -562,6 +563,7 @@ isbound		RETURN(isboundKeyword);
 ischosen	RETURN(ischosenKeyword);
 ispresent	RETURN(ispresentKeyword);
 istemplatekind  RETURN(istemplatekindKeyword);
+json2cbor	RETURN(json2CborKeyword);
 lengthof	RETURN(lengthofKeyword);
 oct2bit		RETURN(oct2bitKeyword);
 oct2char	RETURN(oct2charKeyword);
diff --git a/compiler2/ttcn3/compiler.y b/compiler2/ttcn3/compiler.y
index 58f9fa3fee85e1cb8801656a5aaf61718fc2e15a..8f76f677c2d2e107a9c333e98226f3df6e3d3768 100644
--- a/compiler2/ttcn3/compiler.y
+++ b/compiler2/ttcn3/compiler.y
@@ -832,6 +832,7 @@ static const string anyname("anytype");
 %token bit2intKeyword
 %token bit2octKeyword
 %token bit2strKeyword
+%token cbor2JsonKeyword
 %token char2intKeyword
 %token char2octKeyword
 %token decompKeyword
@@ -853,6 +854,7 @@ static const string anyname("anytype");
 %token ischosenKeyword
 %token ispresentKeyword
 %token istemplatekindKeyword
+%token json2CborKeyword
 %token lengthofKeyword
 %token oct2bitKeyword
 %token oct2charKeyword
@@ -9743,6 +9745,7 @@ PredefinedOpKeyword1:
 | bit2intKeyword { $$ = Value::OPTYPE_BIT2INT; }
 | bit2octKeyword { $$ = Value::OPTYPE_BIT2OCT; }
 | bit2strKeyword { $$ = Value::OPTYPE_BIT2STR; }
+| cbor2JsonKeyword { $$ = Value::OPTYPE_CBOR2JSON; }
 | char2intKeyword { $$ = Value::OPTYPE_CHAR2INT; }
 | char2octKeyword { $$ = Value::OPTYPE_CHAR2OCT; }
 | float2intKeyword { $$ = Value::OPTYPE_FLOAT2INT; }
@@ -9755,6 +9758,7 @@ PredefinedOpKeyword1:
 | int2floatKeyword { $$ = Value::OPTYPE_INT2FLOAT; }
 | int2strKeyword { $$ = Value::OPTYPE_INT2STR; }
 | int2unicharKeyword { $$ = Value::OPTYPE_INT2UNICHAR; }
+| json2CborKeyword { $$ = Value::OPTYPE_JSON2CBOR; }
 | oct2bitKeyword { $$ = Value::OPTYPE_OCT2BIT; }
 | oct2charKeyword { $$ = Value::OPTYPE_OCT2CHAR; }
 | oct2hexKeyword { $$ = Value::OPTYPE_OCT2HEX; }
diff --git a/core/Addfunc.cc b/core/Addfunc.cc
index bd87b71bfca0969b33e8227cd3c8fa73781184cf..3fd8063407139a6eefed4dc54ab46279ddc5bba3 100644
--- a/core/Addfunc.cc
+++ b/core/Addfunc.cc
@@ -14,6 +14,7 @@
  *   Forstner, Matyas
  *   Kovacs, Ferenc
  *   Raduly, Csaba
+ *   Szabo, Bence Janos
  *   Szabo, Janos Zoltan – initial implementation
  *   Zalanyi, Balazs Andor
  *
@@ -34,6 +35,7 @@
 #include "Snapshot.hh"
 #include "TitanLoggerApi.hh"
 #include "../common/UnicharPattern.hh"
+#include "JSON.hh"
 
 #include <openssl/bn.h>
 
@@ -452,8 +454,6 @@ OCTETSTRING int2oct(const INTEGER& value, int length)
       (const char *)value_str);
     if (length < 0) TTCN_error("The second argument (length) of function "
       "int2oct() is a negative integer value: %d.", length);
-    OCTETSTRING ret_val(length);
-    unsigned char *octets_ptr = ret_val.val_ptr->octets_ptr;
     BIGNUM *value_tmp = BN_dup(value_int.get_val_openssl());
     int bytes = BN_num_bytes(value_tmp);
     if (bytes > length) {
@@ -462,6 +462,8 @@ OCTETSTRING int2oct(const INTEGER& value, int length)
         "does not fit in %d octet%s.", (const char *)value_str, length,
         length > 1 ? "s" : "");
     } else {
+      OCTETSTRING ret_val(length);
+      unsigned char *octets_ptr = ret_val.val_ptr->octets_ptr;
       unsigned char* tmp = (unsigned char*)Malloc(bytes * sizeof(unsigned char));
       BN_bn2bin(value_tmp, tmp);
       for (int i = length - 1; i >= 0; i--) {
@@ -1564,7 +1566,6 @@ UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
   Free(user_groups);
 
   char* instr_conv = instr.convert_to_regexp_form();
-  int instr_len = instr.lengthof() * 8;
   
   if (nocase) {
     unichar_pattern.convert_regex_str_to_lowercase(instr_conv);
@@ -1576,6 +1577,7 @@ UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
     int begin_index = pmatch[nmatch].rm_so, end_index = pmatch[nmatch].rm_eo;
     Free(pmatch);
     regfree(&posix_regexp);
+    int instr_len = instr.lengthof() * 8;
     if (end_index > instr_len) TTCN_error("Internal error: The end index "
       "of the substring (%d) to be returned in function regexp() is greater "
       "than the length of the input string (%d).", end_index, instr_len);
@@ -3136,3 +3138,30 @@ OCTETSTRING decode_base64(const CHARSTRING& b64)
   return ret_val;
 }
 
+
+
+OCTETSTRING json2cbor(const UNIVERSAL_CHARSTRING& value) {
+  OCTETSTRING result;
+  TTCN_Buffer buff;
+  value.encode_utf8(buff);
+  const unsigned char* ustr = buff.get_data();
+  const size_t ustr_len = buff.get_len();
+  char* json_str = mcopystr((const char*)ustr);
+  JSON_Tokenizer tok(json_str, ustr_len);
+  Free(json_str);
+  buff.clear();
+  size_t num_of_items = 0;
+  json2cbor_coding(buff, tok, num_of_items);
+  buff.get_string(result);
+  return result;
+}
+
+UNIVERSAL_CHARSTRING cbor2json(const OCTETSTRING& value) {
+  UNIVERSAL_CHARSTRING result;
+  TTCN_Buffer buff;
+  buff.put_os(value);
+  JSON_Tokenizer tok;
+  cbor2json_coding(buff, tok, false);
+  result.decode_utf8(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
+  return result;
+}
diff --git a/core/Addfunc.hh b/core/Addfunc.hh
index 57f465893aef608a7bc1206c881d9f6ddb6e3b93..11dc1a5805672e4b24cc7e8edb6c778385c5a759 100644
--- a/core/Addfunc.hh
+++ b/core/Addfunc.hh
@@ -13,6 +13,7 @@
  *   Forstner, Matyas
  *   Kovacs, Ferenc
  *   Raduly, Csaba
+ *   Szabo, Bence Janos
  *   Szabo, Janos Zoltan – initial implementation
  *   Zalanyi, Balazs Andor
  *
@@ -484,4 +485,7 @@ extern CHARSTRING encode_base64(const OCTETSTRING& msg, boolean use_linebreaks);
 extern CHARSTRING encode_base64(const OCTETSTRING& msg);
 extern OCTETSTRING decode_base64(const CHARSTRING& b64);
 
+extern OCTETSTRING json2cbor(const UNIVERSAL_CHARSTRING& value);
+extern UNIVERSAL_CHARSTRING cbor2json(const OCTETSTRING& value);
+
 #endif
diff --git a/core/JSON.cc b/core/JSON.cc
index bb5b49191f2947cd16a84fa7d4eebb62f42dfa3a..37b36ac6969320c39070cb37f3cda27beef4fd5d 100644
--- a/core/JSON.cc
+++ b/core/JSON.cc
@@ -9,9 +9,27 @@
  *   Baji, Laszlo
  *   Balasko, Jeno
  *   Baranyi, Botond
+ *   Szabo, Bence Janos
  *
  ******************************************************************************/
 #include "JSON.hh"
+#include "../common/memory.h"
+#include "Integer.hh"
+#include "Float.hh"
+#include "Bitstring.hh"
+#include "Hexstring.hh"
+#include "Octetstring.hh"
+#include "Charstring.hh"
+#include "Universal_charstring.hh"
+#include "Addfunc.hh"
+
+#include <openssl/bn.h>
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
 
 // JSON descriptors for base types
 const TTCN_JSONdescriptor_t INTEGER_json_ = { FALSE, NULL, FALSE, NULL, FALSE };
@@ -63,3 +81,485 @@ const TTCN_JSONdescriptor_t ASN_ROID_json_ = { FALSE, NULL, FALSE, NULL, FALSE }
 const TTCN_JSONdescriptor_t ASN_ANY_json_ = { FALSE, NULL, FALSE, NULL, FALSE };
 
 const TTCN_JSONdescriptor_t ENUMERATED_json_ = { FALSE, NULL, FALSE, NULL, FALSE };
+
+
+
+// Never use buff.get_read_data() without checking if it has enough bytes in the
+// buffer.
+const unsigned char* check_and_get_buffer(const TTCN_Buffer& buff, int bytes) {
+  if (bytes < 0) {
+    TTCN_error("Incorrect length byte received: %d, while decoding using cbor2json()", bytes);
+  }
+  if (buff.get_pos() + bytes > buff.get_len()) {
+    TTCN_error("Not enough bytes in bytestream while decoding using cbor2json().");
+  }
+  return buff.get_read_data();
+}
+
+void encode_ulong_long_int_cbor(TTCN_Buffer& buff, int bytes, unsigned long long int value) {
+  for (int i = bytes - 1; i >= 0; i--) {
+    buff.put_c(static_cast<unsigned char>((value >> i*8)));
+  }
+}
+
+
+// major_type parameter needed for the string encoding
+void encode_int_cbor(TTCN_Buffer& buff, int major_type, INTEGER& int_num) {
+  bool is_negative = false;
+  int_val_t num = int_num.get_val();
+  if (num.is_negative()) {
+    major_type = 1 << 5;
+    int_num = (int_num * -1) - 1;
+    num = int_num.get_val();
+    is_negative = true;
+  }
+  if (num.is_native()) {
+    unsigned int uns_num = num.get_val();
+    if (uns_num <= 23) {
+      buff.put_c(static_cast<unsigned char>(major_type + uns_num));
+    } else if (uns_num <= 0xFF) { // 8 bit
+      buff.put_c(static_cast<unsigned char>(major_type + 24));
+      encode_ulong_long_int_cbor(buff, 1, uns_num);
+    } else if (uns_num <= 0xFFFF) { // 16 bit
+      buff.put_c(static_cast<unsigned char>(major_type + 25));
+      encode_ulong_long_int_cbor(buff, 2, uns_num);
+    } else if (uns_num <= 0xFFFFFFFF) { // 32 bit
+      buff.put_c(static_cast<unsigned char>(major_type + 26));
+      encode_ulong_long_int_cbor(buff, 4, uns_num);
+    }
+  } else {
+    BIGNUM* bn = BN_dup(int_num.get_val().get_val_openssl());
+    INTEGER bn_length = BN_num_bytes(bn);
+    long long int long_int = int_num.get_long_long_val();
+    if (bn_length <= 4) { // 32 bit
+      buff.put_c(static_cast<unsigned char>(major_type + 26));
+      encode_ulong_long_int_cbor(buff, 4, long_int);
+    } else if (bn_length <= 8) {
+      buff.put_c(static_cast<unsigned char>(major_type + 27));
+      encode_ulong_long_int_cbor(buff, 8, long_int);
+    } else {
+      // It is a bignum. Encode as bytestring
+      major_type = 6 << 5; // Major type 6 for bignum
+      major_type += is_negative ? 3 : 2; // Tag 2 or 3 for negative
+      buff.put_c(static_cast<unsigned char>(major_type));
+      major_type = 2 << 5; // Major type 2 for bytestring
+      encode_int_cbor(buff, major_type, bn_length); // encode the length of the bignum
+      size_t buff_len = bn_length.get_val().get_val();
+      unsigned char* tmp_num = static_cast<unsigned char*>(Malloc(buff_len*sizeof(unsigned char)));
+      BN_bn2bin(bn, tmp_num);
+      buff.put_s(buff_len, reinterpret_cast<const unsigned char*>(tmp_num));
+      Free(tmp_num);
+    }
+    BN_free(bn);
+  }
+}
+
+
+void decode_int_cbor(TTCN_Buffer& buff, int bytes, INTEGER& value) {
+  const unsigned char* tmp = check_and_get_buffer(buff, bytes);
+  TTCN_Buffer tmp_buf;
+  tmp_buf.put_s(bytes, tmp);
+  OCTETSTRING os;
+  tmp_buf.get_string(os);
+  value = oct2int(os);
+  buff.increase_pos(bytes);
+}
+
+void decode_uint_cbor(TTCN_Buffer& buff, int bytes, unsigned int& value) {
+  value = 0;
+  const unsigned char* tmp = check_and_get_buffer(buff, bytes);
+  for (int i = bytes - 1; i >= 0; i--) {
+    value += *(tmp) << i*8;
+    tmp++;
+  }
+  buff.increase_pos(bytes);
+}
+
+void decode_ulong_long_int_cbor(TTCN_Buffer& buff, int bytes, unsigned long long int& value) {
+  value = 0;
+  const unsigned char* tmp = check_and_get_buffer(buff, bytes);
+  for (int i = bytes - 1; i >= 0; i--) {
+    value += *(tmp) << i*8;
+    tmp++;
+  }
+  buff.increase_pos(bytes);
+}
+
+void decode_integer_cbor(TTCN_Buffer& buff, int minor_type, INTEGER& result) {
+  if (minor_type <= 23) {
+    result = minor_type;
+  } else if (minor_type == 24) { // A number in 8 bits
+    unsigned int num;
+    decode_uint_cbor(buff, 1, num);
+    result = num;
+  } else if (minor_type == 25) { // A number in 16 bits
+    unsigned int num;
+    decode_uint_cbor(buff, 2, num);
+    result = num;
+  } else if (minor_type == 26) { // A number in 32 bits
+    unsigned int num;
+    decode_uint_cbor(buff, 4, num);
+    result = num;
+  } else if (minor_type == 27) { // A number in 64 bits
+    decode_int_cbor(buff, 8, result);
+  }
+}
+
+
+void decode_bytestring_cbor(TTCN_Buffer& buff, JSON_Tokenizer& tok, int minor_type, int tag) {
+  INTEGER length;
+  decode_integer_cbor(buff, minor_type, length);
+  const unsigned char* tmp = check_and_get_buffer(buff, length.get_val().get_val());
+  OCTETSTRING os(length.get_val().get_val(), tmp);
+  buff.increase_pos(length.get_val().get_val());
+  CHARSTRING cs;
+  if (tag == 22 || tag == 23 || tag == 2 || tag == 3) { // base64 or base64url or +-bigint
+    cs = encode_base64(os);
+    // The difference between the base64 and base64url encoding is that the
+    // + is replaced with -, the / replaced with _ and the trailing = padding
+    // is removed.
+    if (tag != 22) { // if tag is not base64 >--> base64url
+      const char* data = (const char*)cs;
+      char* pch = strchr(const_cast<char*>(data),'+');
+      while (pch!=NULL)
+      {
+        *pch = '-';
+        pch=strchr(pch+1,'+');
+      }
+      pch = strchr(const_cast<char*>(data),'/');
+      while (pch!=NULL)
+      {
+        *pch = '_';
+        pch=strchr(pch+1,'/');
+      }
+      // Max 2 padding = is possible
+      if (cs[cs.lengthof()-1] == "=") {
+        cs = replace(cs, cs.lengthof()-1, 1, "");
+      }
+      if (cs[cs.lengthof()-1] == "=") {
+        cs = replace(cs, cs.lengthof()-1, 1, "");
+      }
+    }    
+  } else if (tag == 21) { // base16
+    cs = oct2str(os);
+  }
+  // If the bignum encoded as bytestring is negative the tilde is needed before
+  // the base64url encoding
+  char* tmp_str = mprintf("\"%s%s\"", tag == 3 ? "~" : "", (const char*)cs);
+  tok.put_next_token(JSON_TOKEN_STRING, tmp_str);
+  Free(tmp_str);
+}
+
+// RAW descriptor for raw encoding
+TTCN_RAWdescriptor_t cbor_float_raw_ = {64,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN};
+const TTCN_Typedescriptor_t cbor_float_descr_ = { NULL, NULL, &cbor_float_raw_, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
+
+
+void json2cbor_coding(TTCN_Buffer& buff, JSON_Tokenizer& tok, size_t& num_of_items) {
+  json_token_t token;
+  char* content = NULL;
+  size_t len;
+  size_t prev_pos = tok.get_buf_pos();
+  tok.get_next_token(&token, &content, &len);
+  switch(token) {
+    case JSON_TOKEN_NUMBER: {
+      char *str = mcopystrn(content, len);
+      size_t curr_pos = tok.get_buf_pos();
+      tok.set_buf_pos(prev_pos);
+      bool is_float = false;
+      tok.check_for_number(&is_float);
+      tok.set_buf_pos(curr_pos);
+      if (is_float) {
+        int c = 7 << 5; // Major type 7
+        c += 27; // Minor type 27 (64 bit floating point) always
+        buff.put_c(c);
+        double d;
+        sscanf(str, "%lf", &d);
+        FLOAT f = d;
+        f.encode(cbor_float_descr_, buff, TTCN_EncDec::CT_RAW);
+      } else {
+        int c = 0; // Major type 0
+        INTEGER int_num = str2int(str);
+        encode_int_cbor(buff, c, int_num);
+      }
+      Free(str);
+      num_of_items++;
+      break;
+    }
+    case JSON_TOKEN_STRING:
+    case JSON_TOKEN_NAME: {
+      int c = 3 << 5; // Major type 3
+      INTEGER length = token == JSON_TOKEN_NAME ? len : len - 2; // 2 "-s
+      encode_int_cbor(buff, c, length);
+      char * str = mcopystrn(token == JSON_TOKEN_NAME ? content : content+1, length.get_val().get_val()); // Remove "-s
+      buff.put_string(str);
+      Free(str);
+      num_of_items++;
+      break;
+    }
+    case JSON_TOKEN_ARRAY_START: {
+      int c = 4 << 5; // Major type 4
+      size_t nof_items = 0;
+      TTCN_Buffer sub_buff;
+      while ((prev_pos = tok.get_buf_pos(), tok.get_next_token(&token, NULL, NULL))) {
+        if (token != JSON_TOKEN_ARRAY_END) {
+          tok.set_buf_pos(prev_pos);
+          json2cbor_coding(sub_buff, tok, nof_items);
+        } else {
+          INTEGER num = nof_items;
+          encode_int_cbor(buff, c, num);
+          buff.put_buf(sub_buff);
+          break;
+        }
+      }
+      num_of_items++;
+      break;
+    }
+    case JSON_TOKEN_ARRAY_END:
+      TTCN_error("Unexpected array end character while encoding using json2cbor().");
+      break;
+    case JSON_TOKEN_OBJECT_START: {
+      int c = 5 << 5; // Major type 5
+      size_t nof_items = 0;
+      TTCN_Buffer sub_buff;
+      while ((prev_pos = tok.get_buf_pos(), tok.get_next_token(&token, NULL, NULL))) {
+        if (token != JSON_TOKEN_OBJECT_END) { // todo hibas json eseten vegtelen ciklus?
+          tok.set_buf_pos(prev_pos);
+          json2cbor_coding(sub_buff, tok, nof_items);
+        } else {
+          INTEGER num = nof_items / 2; // num is the number of key-value pairs
+          encode_int_cbor(buff, c, num);
+          buff.put_buf(sub_buff);
+          break;
+        }
+      }
+      num_of_items++;
+      break;
+    }
+    case JSON_TOKEN_OBJECT_END:
+      TTCN_error("Unexpected object end character while encoding using json2cbor().");
+    case JSON_TOKEN_LITERAL_FALSE:
+    case JSON_TOKEN_LITERAL_TRUE:
+    case JSON_TOKEN_LITERAL_NULL: {
+      int c = 7 << 5; // Major type 7
+      INTEGER i;
+      if (token == JSON_TOKEN_LITERAL_FALSE) {
+        i = 20;
+      } else if (token == JSON_TOKEN_LITERAL_TRUE) {
+        i = 21;
+      } else if (token == JSON_TOKEN_LITERAL_NULL) {
+        i = 22;
+      }
+      encode_int_cbor(buff, c, i);
+      num_of_items++;
+      break;
+    }
+    default:
+      TTCN_error("Unexpected json token %i, while encoding using json2cbor().", token);
+  }
+}
+
+void cbor2json_coding(TTCN_Buffer& buff, JSON_Tokenizer& tok, bool in_object) {
+  unsigned char type = *(check_and_get_buffer(buff, 1));
+  buff.increase_pos(1);
+  int major_type = type >> 5; // First 3 bit of byte
+  int minor_type = type & 0x1F; // Get the last 5 bits
+  switch(major_type) {
+    case 0: { // Integer
+      INTEGER i;
+      decode_integer_cbor(buff, minor_type, i);
+      if (i.is_native()) {
+        char* tmp_str = mprintf("%u", i.get_val().get_val());
+        tok.put_next_token(JSON_TOKEN_NUMBER, tmp_str);
+        Free(tmp_str);
+      } else {
+        char* tmp_str = i.get_val().as_string();
+        tok.put_next_token(JSON_TOKEN_NUMBER, tmp_str);
+        Free(tmp_str);
+      }
+      break;
+    }
+    case 1: // Negative integer
+      switch (minor_type) {
+        case 24: { // Integer on 1 byte
+          unsigned int num;
+          decode_uint_cbor(buff, 1, num);
+          char* tmp_str = mprintf("%d", (num+1)*-1);
+          tok.put_next_token(JSON_TOKEN_NUMBER, tmp_str);
+          Free(tmp_str);
+          break;
+        }
+        case 25: { // Integer on 2 byte
+          unsigned int num;
+          decode_uint_cbor(buff, 2, num);
+          char* tmp_str = mprintf("%d", (num+1)*-1);
+          tok.put_next_token(JSON_TOKEN_NUMBER, tmp_str);
+          Free(tmp_str);
+          break;
+        }
+        case 26: { // Integer on 4 byte
+          unsigned long long int num;
+          decode_ulong_long_int_cbor(buff, 4, num);
+          INTEGER i;
+          i.set_long_long_val((num+1)*-1);
+          char* tmp_str = i.get_val().as_string();
+          tok.put_next_token(JSON_TOKEN_NUMBER, tmp_str);
+          Free(tmp_str);
+          break;
+        }
+        case 27: { // Integer on 8 byte
+          INTEGER i;
+          decode_int_cbor(buff, 8, i);
+          i = i + 1;
+          i = i * -1;
+          char* tmp_str = i.get_val().as_string();
+          tok.put_next_token(JSON_TOKEN_NUMBER, tmp_str);
+          Free(tmp_str);
+          break;
+        }
+        default:
+          if (minor_type < 24) { // Integer  0 <= num <= 24
+            char* tmp_str = mprintf("%d", (minor_type+1)*-1);
+            tok.put_next_token(JSON_TOKEN_NUMBER, tmp_str);
+            Free(tmp_str);
+          }
+      }
+      break;
+    case 2: // Bytestring, encoded into a base64url json string
+      decode_bytestring_cbor(buff, tok, minor_type, 23); // base64url by default
+      break;
+    case 3: { // String
+      INTEGER length;
+      decode_integer_cbor(buff, minor_type, length);
+      const unsigned char* tmp = check_and_get_buffer(buff, length.get_val().get_val());
+      
+      char* json_str = mcopystrn((const char*)tmp, length.get_val().get_val());
+      if (in_object) {
+        tok.put_next_token(JSON_TOKEN_NAME, json_str);
+      } else {
+        char* tmp_str = mprintf("\"%s\"", json_str);
+        tok.put_next_token(JSON_TOKEN_STRING, tmp_str);
+        Free(tmp_str);
+      }
+      Free(json_str);
+      buff.increase_pos(length.get_val().get_val());
+      break;
+    }
+    case 4: { // Array
+      tok.put_next_token(JSON_TOKEN_ARRAY_START, NULL);
+      INTEGER num_of_items;
+      decode_integer_cbor(buff, minor_type, num_of_items);
+      for (INTEGER i = 0; i < num_of_items; i = i + 1) {
+        cbor2json_coding(buff, tok, false);
+      }
+      tok.put_next_token(JSON_TOKEN_ARRAY_END, NULL);
+      break;
+    }
+    case 5: { // Object
+      tok.put_next_token(JSON_TOKEN_OBJECT_START, NULL);
+      INTEGER num_of_items;
+      decode_integer_cbor(buff, minor_type, num_of_items);
+      num_of_items = num_of_items * 2; // Number of all keys and values
+      for (INTEGER i = 0; i < num_of_items; i = i + 1) {
+        // whether to put : or , after the next token
+        in_object = i.get_val().get_val() % 2 == 0;
+        cbor2json_coding(buff, tok, in_object); 
+      }
+      tok.put_next_token(JSON_TOKEN_OBJECT_END, NULL);
+      break;
+    }
+    case 6: {
+      int tag = minor_type;
+      switch(tag) {
+        case 2: // Positive bignum
+        case 3: // Negative bignum
+        case 21: // bytestring as base16
+        case 22: // bytestring as base64
+        case 23: // bytestring as base64url
+          type = *(check_and_get_buffer(buff, 1));
+          buff.increase_pos(1);
+          minor_type = type & 0x1F; // Get the last 5 bits
+          decode_bytestring_cbor(buff, tok, minor_type, tag);
+          break;
+        default:
+          cbor2json_coding(buff, tok, in_object);
+      }
+      break;
+    }
+    case 7: // Other values
+      switch (minor_type) {
+        case 20: // False
+          tok.put_next_token(JSON_TOKEN_LITERAL_FALSE, NULL);
+          break;
+        case 21: // True
+          tok.put_next_token(JSON_TOKEN_LITERAL_TRUE, NULL);
+          break;
+        case 22: // NULL
+        tok.put_next_token(JSON_TOKEN_LITERAL_NULL, NULL);
+          break;
+        case 25: { // Half precision float 16 bit
+          // Decoding algorithm from the standard
+          const unsigned char* halfp = check_and_get_buffer(buff, 2);
+          buff.increase_pos(2);
+          int half = (halfp[0] << 8) + halfp[1];
+          int exp = (half >> 10) & 0x1f;
+          int mant = half & 0x3ff;
+          double val;
+          if (exp == 0) val = ldexp(mant, -24);
+          else if (exp != 31) val = ldexp(mant + 1024, exp - 25);
+          else val = mant == 0 ? INFINITY : NAN;
+          val = half & 0x8000 ? -val : val;
+          FLOAT f = val;
+          f.JSON_encode(cbor_float_descr_, tok);
+          break;
+        }
+        case 26: { // Single precision float 32bit
+          OCTETSTRING os(4, check_and_get_buffer(buff, 4));
+          buff.increase_pos(4);
+          INTEGER i = oct2int(os);
+          // Some non standard way but it is widely accepted
+          union
+          {
+            unsigned int num;
+            float fnum;
+          } my_union;
+          my_union.num = i.get_long_long_val();
+          float f2 = my_union.fnum;
+          FLOAT f = f2;
+          f.JSON_encode(cbor_float_descr_, tok);
+          break;
+        }
+        case 27: { // Double precision float 64bit
+          cbor_float_raw_.fieldlength = 64;
+          FLOAT f;
+          OCTETSTRING os(8, check_and_get_buffer(buff, 8));
+          INTEGER i = oct2int(os);
+          if (i.get_long_long_val() != 0x7FF8000000000000) { // NAN    
+            f.decode(FLOAT_descr_, buff, TTCN_EncDec::CT_RAW);
+            f.JSON_encode(cbor_float_descr_, tok);
+          } else {
+            tok.put_next_token(JSON_TOKEN_STRING, "\"not_a_number\"");
+            buff.increase_pos(8);
+          }
+          break;
+        }
+        default: {
+          // put the simple value into the the json
+          if (minor_type >= 0 && minor_type <= 23) {
+            char* tmp_str = mprintf("%d", minor_type);
+            tok.put_next_token(JSON_TOKEN_NUMBER, tmp_str);
+            Free(tmp_str);
+          } else if (minor_type == 24) { // The value is on the next byte
+            int simple_value = *(buff.get_read_data());
+            buff.increase_pos(1);
+            char* tmp_str = mprintf("%d", simple_value);
+            tok.put_next_token(JSON_TOKEN_NUMBER, tmp_str);
+            Free(tmp_str);
+          }
+        }
+      }
+      break;
+    default:
+      TTCN_error("Unexpected major type %i while decoding using cbor2json().", major_type);
+  }
+}
diff --git a/core/JSON.hh b/core/JSON.hh
index 854453cc311f131acbb02dc9107226258839e958..a75b84b6a692bdb7e6eff9ef07ef16afbf8ada46 100644
--- a/core/JSON.hh
+++ b/core/JSON.hh
@@ -8,6 +8,7 @@
  * Contributors:
  *   Balasko, Jeno
  *   Baranyi, Botond
+ *   Szabo, Bence Janos
  *
  ******************************************************************************/
 #ifndef JSON_HH_
@@ -15,6 +16,9 @@
 
 #include "Types.h"
 
+class TTCN_Buffer;
+class JSON_Tokenizer;
+
 /** Descriptor for JSON encoding/decoding during runtime */
 struct TTCN_JSONdescriptor_t 
 {
@@ -131,5 +135,10 @@ enum json_metainfo_t {
 #define JSON_DEC_METAINFO_VALUE_ERROR "Invalid meta info for field '%s'"
 #define JSON_DEC_METAINFO_NOT_APPLICABLE "Meta info not applicable to field '%s'"
 
+
+// Functions for conversion between json and cbor and vice versa
+void json2cbor_coding(TTCN_Buffer& buff, JSON_Tokenizer& tok, size_t& num_of_items);
+void cbor2json_coding(TTCN_Buffer& buff, JSON_Tokenizer& tok, bool in_object);
+
 #endif	/* JSON_HH_ */
 
diff --git a/regression_test/json/Cbor.ttcn b/regression_test/json/Cbor.ttcn
new file mode 100644
index 0000000000000000000000000000000000000000..aeb6b9b26f468fc7206d0275e8c8181386b91c1e
--- /dev/null
+++ b/regression_test/json/Cbor.ttcn
@@ -0,0 +1,981 @@
+/******************************************************************************
+ * Copyright (c) 2000-2017 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Szabo, Bence Janos
+ *
+ ******************************************************************************/
+module Cbor {
+
+	type component EmptyCT {
+
+	}
+
+	testcase tc_cbor_integer() runs on EmptyCT {
+		var octetstring os;
+		var universal charstring json, decoded, decoded_json;
+
+		json := "0"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "1"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "23"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "24"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "233"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "255" // 8 bit max
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "256"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "25056"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "65535"  // 16 bit max
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "65536"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "6553235"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "2147483647" // 32 bit max
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "2147483648"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "214732483648"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "9223372036854775807" // 64 bit max
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-0"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		json := "0";
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-1"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-23"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-24"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-233"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-255" 
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-256" // 8 bit max
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-257"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-25056"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-65535"  
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-65536" // 16 bit max
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-65537"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-6553235"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-2147483647" // 32 bit max
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-2147483648"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-214732483648"
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "-9223372036854775807" // 64 bit max
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		// Bignums
+		json := "18446744073709551616"
+		decoded_json := "\"AQAAAAAAAAAA\"";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		json := "-1844674407370955161634"
+		decoded_json := "\"~ZAAAAAAAAAAh\"";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+
+		setverdict(pass);
+	}
+
+	testcase tc_cbor_string() runs on EmptyCT {
+		var universal charstring json, decoded;
+		var octetstring os;
+
+		json := "\"a\"";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "\"abc\"";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "\"\n\t\"";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "\"Á\"";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "\"Á	Ä	Č	Ď	É	Í	Ĺ	Ľ	Ň	Ó	Ô	Ŕ	Š	Ť	Ú	Ý	Ž\"";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		setverdict(pass);
+	}
+
+	testcase tc_cbor_array() runs on EmptyCT {
+		var universal charstring json, decoded;
+		var octetstring os;
+
+		json := "[]";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "[0]";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "[1]";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "[1,2,3]";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "[\"abc\"]";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "[\"abc\",414,\"Ň\n\",34]";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "[1,[2]]";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "[1,2,[3,4,[\"ot\",6,7],5432535353535432,-4242.243200],2524254242232,false,3.130000,true,null]"; //todo float es minden mas tipus is listaba es a masikba
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		setverdict(pass);
+	}
+
+	testcase tc_cbor_map() runs on EmptyCT {
+		var universal charstring json, decoded;
+		var octetstring os;
+
+		json := "{}";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "{\"a\":1}";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "{\"a\":\"abc\"}";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "{\"a\":[[1,2,3],[\"ab\"]]}";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "{\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\":[[1,2,3],[\"ab\"]]}";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "{\"a\":1,\"b\":2}";
+		os := json2cbor(json);
+		log(os);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "{\"a\":1,\"b\":2,\"abcd\":[[1,2,3],[\"ab\"]]}";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "{\"a\":1,\"b\":2,\"abcd\":[[1,2,3],[\"ab\"]],\"osg\":{\"a\":1,\"b\":2},\"aa\":false,\"fdg\":true,\"aad\":null}";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "{\"a\":1,\"b\":2,\"abcd\":[[1,2,3],{\"a\":1,\"b\":2,\"abcd\":[[1,2,3],[\"ab\"]],\"osg\":{\"a\":1,\"rr\":2421.113453,\"b\":2}}],\"osg\":{\"a\":1,\"b\":2}}";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		setverdict(pass);
+	}
+
+	testcase tc_cbor_bool() runs on EmptyCT {
+		var universal charstring json, decoded;
+		var octetstring os;
+
+		json := "false";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		json := "true";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		setverdict(pass);
+	}
+
+	testcase tc_cbor_null() runs on EmptyCT {
+		var universal charstring json, decoded;
+		var octetstring os;
+
+		json := "null";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, json)) {
+			setverdict(fail, match(decoded, json));
+		}
+
+		setverdict(pass);
+	}
+
+	testcase tc_cbor_float() runs on EmptyCT {
+		var universal charstring json, decoded, decoded_json;
+		var octetstring os;
+
+		json := "1.0";
+		decoded_json := "1.000000";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		json := "1.1111";
+		decoded_json := "1.111100";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		json := "-1.1111";
+		decoded_json := "-1.111100";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		json := "2311.1111";
+		decoded_json := "2311.111100";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		json := "1.0e+300";
+		decoded_json := "1.000000e+300";
+		os := json2cbor(json);
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		// Infinity and NAN is not present in JSON and encoded as strings
+
+		// 16 bit float decodings from the standard: https://tools.ietf.org/html/rfc7049#section-2.3
+		os := 'f90000'O;
+		decoded_json := "0.000000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f98000'O;
+		decoded_json := "-0.000000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f93c00'O;
+		decoded_json := "1.000000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f93e00'O;
+		decoded_json := "1.500000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f97bff'O;
+		decoded_json := "65504.000000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f90001'O;
+		decoded_json := "5.960464e-08";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f90400'O;
+		decoded_json := "6.103516e-05";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f9c400'O;
+		decoded_json := "-4.000000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f97c00'O;
+		decoded_json := "\"infinity\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f9fc00'O;
+		decoded_json := "\"-infinity\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'f97e00'O;
+		decoded_json := "\"not_a_number\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '82F9C400F97BFF'O;
+		decoded_json := "[-4.000000,65504.000000]";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'A26161F9C4006162F97BFF'O;
+		decoded_json := "{\"a\":-4.000000,\"b\":65504.000000}";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		// 32 bit float decodings from the standard: https://tools.ietf.org/html/rfc7049#section-2.3
+
+		os := 'fa47c35000'O;
+		decoded_json := "100000.000000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'fa7f7fffff'O;
+		decoded_json := "3.402823e+38";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'fa7f800000'O;
+		decoded_json := "\"infinity\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'faff800000'O;
+		decoded_json := "\"-infinity\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'fa7fc00000'O;
+		decoded_json := "\"not_a_number\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'fa47c35000'O;
+		decoded_json := "100000.000000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '82FA47C35000fa7f7fffff'O;
+		decoded_json := "[100000.000000,3.402823e+38]";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'A26161FA47C350006162fa7f7fffff'O;
+		decoded_json := "{\"a\":100000.000000,\"b\":3.402823e+38}";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		// 64 bit float decodings from the standard: https://tools.ietf.org/html/rfc7049#section-2.3
+
+		os := 'fb3ff199999999999a'O;
+		decoded_json := "1.100000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'fb7e37e43c8800759c'O;
+		decoded_json := "1.000000e+300";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'fbc010666666666666'O;
+		decoded_json := "-4.100000";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'fb7ff0000000000000'O;
+		decoded_json := "\"infinity\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'fbfff0000000000000'O;
+		decoded_json := "\"-infinity\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'fb7ff8000000000000'O;
+		decoded_json := "\"not_a_number\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '82FBC010666666666666fbfff0000000000000'O;
+		decoded_json := "[-4.100000,\"-infinity\"]";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'A26161FBC0106666666666666162fbfff0000000000000'O;
+		decoded_json := "{\"a\":-4.100000,\"b\":\"-infinity\"}";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		setverdict(pass);
+	}
+
+
+	testcase tc_cbor_bytestring() runs on EmptyCT {
+		var universal charstring json, decoded, decoded_json;
+		var octetstring os;
+
+		os := '420102'O;
+		decoded_json := "\"AQI\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '4421426597'O;
+		decoded_json := "\"IUJllw\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '456449455446'O;
+		decoded_json := "\"ZElFVEY\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '5821644945544ABCDAD3432ADCF342785410246532643652135421421ABCDACDC6B536'O;
+		decoded_json := "\"ZElFVEq82tNDKtzzQnhUECRlMmQ2UhNUIUIavNrNxrU2\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '8243010103425345'O;
+		decoded_json := "[\"AQED\",\"U0U\"]";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'A26161430101036162425345'O;
+		decoded_json := "{\"a\":\"AQED\",\"b\":\"U0U\"}";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		// With base64url tag
+		os := 'D7420102'O;
+		decoded_json := "\"AQI\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'D74421426597'O;
+		decoded_json := "\"IUJllw\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'D7456449455446'O;
+		decoded_json := "\"ZElFVEY\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'D75821644945544ABCDAD3432ADCF342785410246532643652135421421ABCDACDC6B536'O;
+		decoded_json := "\"ZElFVEq82tNDKtzzQnhUECRlMmQ2UhNUIUIavNrNxrU2\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '82D743010103D7425345'O;
+		decoded_json := "[\"AQED\",\"U0U\"]";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'A26161D7430101036162D7425345'O;
+		decoded_json := "{\"a\":\"AQED\",\"b\":\"U0U\"}";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		// With base64 encoding tag
+		os := 'D6420102'O;
+		decoded_json := "\"AQI=\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'D64421426597'O;
+		decoded_json := "\"IUJllw==\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'D6456449455446'O;
+		decoded_json := "\"ZElFVEY=\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'D65821644945544ABCDAD3432ADCF342785410246532643652135421421ABCDACDC6B536'O;
+		decoded_json := "\"ZElFVEq82tNDKtzzQnhUECRlMmQ2UhNUIUIavNrNxrU2\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '82D643010103D6425345'O;
+		decoded_json := "[\"AQED\",\"U0U=\"]";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'A26161D6430101036162D6425345'O;
+		decoded_json := "{\"a\":\"AQED\",\"b\":\"U0U=\"}";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		// With base16 encoding tag
+		os := 'D5420102'O;
+		decoded_json := "\"0102\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'D54421426597'O;
+		decoded_json := "\"21426597\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'D5456449455446'O;
+		decoded_json := "\"6449455446\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'D55821644945544ABCDAD3432ADCF342785410246532643652135421421ABCDACDC6B536'O;
+		decoded_json := "\"644945544ABCDAD3432ADCF342785410246532643652135421421ABCDACDC6B536\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := '82D543010103D5425345'O;
+		decoded_json := "[\"010103\",\"5345\"]";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'A26161D5430101036162D5425345'O;
+		decoded_json := "{\"a\":\"010103\",\"b\":\"5345\"}";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		setverdict(pass);
+	}
+
+	testcase tc_cbor_simple_values() runs on EmptyCT {
+		var universal charstring json, decoded, decoded_json;
+		var octetstring os;
+
+		os := 'F0'O;
+		decoded_json := "16";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'F7'O;
+		decoded_json := "23";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'F818'O;
+		decoded_json := "24";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		os := 'F8FF'O;
+		decoded_json := "255";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		setverdict(pass);
+	}
+
+
+	// tags other than 2,3,21,22,23 are ignored
+	testcase tc_cbor_decode_other_tags() runs on EmptyCT {
+		var universal charstring json, decoded, decoded_json;
+		var octetstring os;
+
+		// tag 17
+		os := 'D14401020304'O; // this will be decoded to a base64url string by default
+		decoded_json := "\"AQIDBA\"";
+		decoded := cbor2json(os);
+		if (not match(decoded, decoded_json)) {
+			setverdict(fail, match(decoded, decoded_json));
+		}
+
+		setverdict(pass);
+	}
+
+	control {
+
+		execute(tc_cbor_integer());
+		execute(tc_cbor_string());
+		execute(tc_cbor_array());
+		execute(tc_cbor_map());
+		execute(tc_cbor_bool());
+		execute(tc_cbor_null());
+		execute(tc_cbor_float());
+		execute(tc_cbor_bytestring());
+		execute(tc_cbor_simple_values());
+		execute(tc_cbor_decode_other_tags());
+
+	}
+}
diff --git a/regression_test/json/JSON.cfg b/regression_test/json/JSON.cfg
index 4bd6743aab7e13ef3887391e588a5e7ddc090ced..684b527d59c3b4bae4b384f9c18634d5be603f18 100644
--- a/regression_test/json/JSON.cfg
+++ b/regression_test/json/JSON.cfg
@@ -7,6 +7,7 @@
 #
 # Contributors:
 #   Balasko, Jeno
+#   Szabo, Bence Janos
 #
 ###############################################################################
 [MODULE_PARAMETERS]
@@ -83,6 +84,7 @@ AttributeTestcases.control
 #AttributeTestcases.tc_attribute_prettyprint1
 #AttributeTestcases.tc_attribute_prettyprint2
 #AttributeTestcases.tc_attribute_union
+Cbor.control
 [GROUPS]
 # In this section you can specify groups of hosts. These groups can be used inside the
 # [COMPONENTS] section to restrict the creation of certain PTCs to a given set of hosts.
diff --git a/regression_test/json/Makefile b/regression_test/json/Makefile
index 6362c39327d527fe77d83df9aede414d73895ccc..9acbff0b7ec176da522b9a775b8af2499313be93 100644
--- a/regression_test/json/Makefile
+++ b/regression_test/json/Makefile
@@ -19,7 +19,7 @@ include $(TOPDIR)/Makefile.regression
 
 TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX)
 
-TTCN3_MODULES = Types.ttcn Functions.ttcn AttributeTestcases.ttcn Testcases.ttcn SemanticCheck.ttcn OtherTypes.ttcn
+TTCN3_MODULES = Types.ttcn Functions.ttcn AttributeTestcases.ttcn Testcases.ttcn SemanticCheck.ttcn OtherTypes.ttcn Cbor.ttcn
 
 ASN1_MODULES = JsonData.asn
 
diff --git a/usrguide/referenceguide.doc b/usrguide/referenceguide.doc
index adcd6c8be3c5561fd64978417e0ffbdf09b4f778..cfac60a8886ab28801fe57b908dd33a235ad1c13 100644
Binary files a/usrguide/referenceguide.doc and b/usrguide/referenceguide.doc differ