Subject: [Cbor] translating simple value undef to JSON

From: "Lundblade, Laurence" <[email-masked]>
Date: Thu, 20 Oct 2016 20:02:30 +0000

Seems like JSON doesn’t have the value “undef” but CBOR does. Is there some thinking on how to translate it, or should any protocol designed to convert to JSON just not use undef?

Thx

LL

---

From: Sean Leonard <[email-masked]>
Date: Thu, 20 Oct 2016 15:59:10 -0700

> Seems like JSON doesn’t have the value “undef” but CBOR does. Is there some thinking on how to translate it, or should any protocol designed to convert to JSON just not use undef?

Don't use undef.

At least, not in "that way" (i.e., where you expect undefined to exist 
in JSON). It won't round-trip. You would need to co-opt another value 
and mark it "special", but that would take away from being able to use 
that value in your protocol. I.e., adds complexity.

I suppose you might consider using an invalid UTF-16 sequence, such as 
the single character "\uDFFF". That will not round-trip into CBOR 
strings because CBOR only permits UTF-8, which /should/ be well-formed. 
(There is leeway in RFC 7049 that leaves open the possibility that 
ill-formed UTF-8 might be acceptable; check it out.) Your special 
encoder or decoder could recognize this special character and convert 
accordingly.

Sean

---

From: "Lundblade, Laurence" <[email-masked]>
Date: Fri, 21 Oct 2016 01:11:41 +0000

OK. Thx. Didn’t have my heart set on it and have lots of other reasonable options. 

LL

On Oct 20, 2016, at 3:59 PM, Sean Leonard <[email-masked]> wrote:

> At least, not in "that way" (i.e., where you expect undefined to exist in JSON). It won't round-trip. You would need to co-opt another value and mark it "special", but that would take away from being able to use that value in your protocol. I.e., adds complexity.
> 
> I suppose you might consider using an invalid UTF-16 sequence, such as the single character "\uDFFF". That will not round-trip into CBOR strings because CBOR only permits UTF-8, which /should/ be well-formed. (There is leeway in RFC 7049 that leaves open the possibility that ill-formed UTF-8 might be acceptable; check it out.) Your special encoder or decoder could recognize this special character and convert accordingly.
> 
> Sean
> 
> 
> _______________________________________________
> CBOR mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/cbor