Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:01:15+00:00 2026-06-12T04:01:15+00:00

I have the following enumeration in Java on Android and I would like to

  • 0

I have the following enumeration in Java on Android and I would like to be able to deserialize an integer in an incoming JSON string/object into this Enum type. I have been getting hits on Jackson and GSON but nothing on the JSON.org package, which I am using.

Is there an easy way to do this or do I need to alter the JSON decoder? Thanks.

public enum ValueEnum {

    ONE(1),
    TWO(2),
    THREE(3);

    private int value;

    private ValueEnum(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:01:16+00:00Added an answer on June 12, 2026 at 4:01 am

    ValueEnum.values() will return you array of ValueEnum[] then you can iterate over array and check for Value

    public static ValueEnum valueOf(int value) {
            ValueEnum[] valueEnums = ValueEnum.values();
            for (ValueEnum valueEnum : valueEnums) {
                if (valueEnum.getValue() == value)
                {
                    return valueEnum;
                }
            }
            return DEFAULT;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following implicit conversion for java.util.Enumerations implicit def enumerationIterator[A](e : Enumeration[A]) :
I have the following class: public class DocketType : Enumeration<DocketType, int, string> { public
I have the following segment of a java file: Integer x; Integer y; Face
I have the following json returned string: [{status:2,id:-1,content:User has entered wrong input,time:1346765646202}] (as you
I have following xsd: <xs:simpleType name=resultcode> <xs:restriction base=xs:integer> <xs:enumeration value=0 id=Approved_no_error> <xs:annotation> <xs:appinfo> <jxb:typesafeEnumMember
I currently have a class file with the following enumeration: using System; namespace Helper
I have this timer function, it gives me following exception. Collection was modified; enumeration
I have the following enumeration Enum NodeStatusTypes Undefined Grant Deny End Enum and I'm
I have the following code: private static boolean hasTargetStyle(AttributeSet attributes) { final Enumeration<?> attributeNames
What would it mean to create something like the following? <xsd:simpleType name=myField> <xsd:restriction base=xsd:boolean/>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.