Lottemint / json-to-bubble-object

Convert a JSON object to a Bubble object for plugin purposes. (Bubble.is)
14 stars 7 forks source link

Conversion not supporting Long type #6

Open redvivi opened 3 years ago

redvivi commented 3 years ago

Hello,

I have an issue using this piece of code:

Object

{
   "segment":{
      "endTimeOffset":{
         "seconds":"5",                   <------ (1)
         "nanos":240000000
      }
   }
}

Converted object through Bubble.io engine using json-to-bubble

{
   "_p_segment.endTimeOffset.seconds.low":5,
   "_p_segment.endTimeOffset.seconds.high":0,
   "_p_segment.endTimeOffset.seconds.unsigned":false,
   "_p_segment.endTimeOffset.nanos":240000000
}

After some research, it looks like the type of (1) is of Long type, and must be converted accordingly to a number using toNumber()function.

Lottemint commented 3 years ago

Ah. Yeah. Thanks for sharing more details, and sorry for the late reply!

This library doesn't parse strings to numbers. It keeps values as is.

redvivi commented 3 years ago

Long type is a string 😅 ?

My interpretation is that the library does not keep the Long-typed value as it is, but parse it in a way that Bubble can’t use it.

Google’s Protobuf reference contains more details about the Long types.

See https://github.com/protobufjs/protobuf.js/issues/50 as well.

Lottemint commented 3 years ago

image

redvivi commented 3 years ago

I understand, what I am saying is that using the method convert(APIResponseFromGoogle) will end up with :

{
   "_p_segment.endTimeOffset.seconds.low":5,
   "_p_segment.endTimeOffset.seconds.high":0,
   "_p_segment.endTimeOffset.seconds.unsigned":false,
   "_p_segment.endTimeOffset.nanos":240000000
}

versus what is declared as custom object:

{
   "segment":{
      "endTimeOffset":{
         "seconds":"5",                   <------ (1)
         "nanos":240000000
      }
   }
}

resulting the parsed object as unprocessable.

So frankly speaking I have not determined yet what was the initial object representation that leads to the converted object ends up with low, high, unsigned keys, but happy to provide more data under your recommendation to investigate.