4

I am using JSON-Lib library to do JSON encoding. Can't do it with GSON (my preferred library when dealing with JSON in Java) or any other libraries because unfortunately my application needs to be Java 1.4 compliant.

My question is:

What's the best way to encode BigDecimal values (values representing money) in that library? Is it just serializing BigDecimal objects as strings with my desired precision?

4
  • If you're just going to display the values, then a string works best. Commented Aug 10, 2011 at 13:22
  • No, I am also planning to use the values in calculations and other stuff... Commented Aug 10, 2011 at 13:25
  • 1
    See the answer to this question: stackoverflow.com/questions/2556338/currency-math-in-javascript Commented Aug 10, 2011 at 13:27
  • How much money are you dealing with? You can hold an awful lot of cents in a Java long. Commented Aug 10, 2011 at 16:07

1 Answer 1

1

According to this message, JSON-Lib supports BigDecimal via the JSONUtils class.

Sign up to request clarification or add additional context in comments.

1 Comment

Excellent! Thanks a lot for the response. It supports BigDecimal. No problem at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.