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

  • Home
  • SEARCH
  • 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 9211889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:23:58+00:00 2026-06-18T01:23:58+00:00

I have created json variable called grouptypejson as mentioned below:- var grouptypejson = {

  • 0

I have created json variable called “grouptypejson” as mentioned below:-

var grouptypejson = {
    "opt": [
             {
                "n": "@SampleResource.GENERIC",
                "v": 0
             },
             {
                "n": "@SampleResource.DEPARTMENT",
                "v": 1
             }
           ]
}; 

The above json variable is defined globally in cshtml page under javascript body.

I am using hardcoded value i.e. “v”:0 & “v”:1

Instead of using hardcoded value, I want to get the number via enum which is defined under models namespace i.e. mentioned below:-

namespace My.Sample.Models.Enums
{
    public enum FilterEnum
    {
        Generic = 0,
        Department,
        All
    }
}

I want to read the value using the above enum and store the same at hard coded place

i.e. "v":0 & "v":1

I don’t know how to get the enum value as integer and store at “v”.

I tried using the following mentioned below but the result was Generic & Department respectively. Replaced 0 & 1 with the below string at the above json variable.

 "v":"@FilterEnum.GENERIC" & "v":"@FilterEnum.DEPARTMENT"

Please guide me how to do the same, I am including the enum namespace in my html page.

Please correct me if i have written anything wrong. I am beginner & learner.

Thanks in advance.

  • 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-18T01:23:59+00:00Added an answer on June 18, 2026 at 1:23 am

    You can cast enum to int:

    var grouptypejson = {
        "opt": [
                 {
                    "n": "@SampleResource.GENERIC",
                    "v": @((int)SampleResource.GENERIC)
                 },
                 {
                    "n": "@SampleResource.DEPARTMENT",
                    "v": @((int)SampleResource.DEPARTMENT)
                 }
               ]
    }; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some JSON I am working with in an instance variable called stream.
I have a javascript function create(tagName, options) and the options variable is a JSON
I have created an empty json object having an array itemlist(which further contains itemid
I have created one application in j2me, I have used json parsing in that
I have a news feed where items in the feed are created from JSON
I have a View (created using Backbone.View.extend) and a JSON object, I actually get
I have ASP MVC 3 application. I created WCF REST JSON Service and added
I have a JSON array like this: { forum:[ { id:1, created:2010-03-19 , updated:2010-03-19
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
I have created an API that requires a POST using JSON. This API is

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.