Sankaranarayanan
Sankaranarayanan

Reputation: 11

How to avoid type conversion in flex from string to number?

I am returning 12345678910111213171819 from java to flex, with in xml tags using http serivce. The result format is object.

but when I display the text it automatically converted or treated as number so it displays like 1.234567891011121317181 x e^21 ....

How to avoid this?

Thanks in advance. Regards, Sankara narayanan Ekambaranathan.

Upvotes: 1

Views: 753

Answers (3)

Ashish
Ashish

Reputation: 11

Well the easiest solution is just a little workaround to the issue:

Instead of sending the open data like 12345678910111213171819

Convert the data into Base 64 Encoding While transmitting MTIzNDU2Nzg5MTAxMTEyMTMxNzE4MTk=

In Flex Convert back the data using the standard Base 64 Decoder provided with flex to convert it back into String instead of number format during XML parsing ;)

Upvotes: 1

PatrickS
PatrickS

Reputation: 9572

Can't you simply coerce it with String()?

var returnedObject:String = String(123463457695);

Upvotes: 1

Vadim Belyaev
Vadim Belyaev

Reputation: 2859

I faced the same problem on one of my projects.

After a lot of googling and investigation I fixed it by changing result format to XML and manually parsing the XML with explicit type conversions.

Another (actually, more correct) way is to define a schema for the response and somehow apply it to the XML decoder but I haven't found an easy way to do it.

Upvotes: 0

Related Questions