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 7889679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:09:38+00:00 2026-06-03T06:09:38+00:00

I want to use the map using JavaScript. I could get the expected output

  • 0

I want to use the map using JavaScript.

I could get the expected output if I use static data.

var tempMap={91: "Live", 41: "Aggr-Pack", 92: "Test", 118: "Group", 115: "Inner Cartons", 122: "SNDC", 102: "Web Service", 82: "EXTERNAL_DEF", 137: "PARTIAL", 72: "Return", 112: "Kit Master Cartons", 46: "SHIP", 134: "VEHICLE_TYPE", 121: "SGTIN", 135: "VEHICLE_ID", 45: "DE-COM", 113: "Bulk Cartons ", 136: "VEHICLE_COLOR", 131: "CARRIER", 52: "Invoice Number", 101: "File", 114: "Product Master Cartons ", 81: "GLN", 42: "Kit", 53: "Shipping Number", 47: "RECEIVE", 111: "Pallet", 133: "SHIPMENT_TYPE", 71: "Sale", 43: "DIS", 116: "Kits", 21: "en", 123: "SSCC", 22: "es", 117: "Products", 44: "COM", 132: "EXPECTED_DELIVERY_DATE", 73: "Transfer", 51: "Purchase Order Number"};
var key=116;
alert(tempMap[key]);

I want to create the dynamic map from response.

The response is

"{91=Live, 41=Aggr-Pack, 92=Test, 118=Group, 115=Inner Cartons, 122=SNDC, 102=Web Service, 82=EXTERNAL_DEF, 137=PARTIAL, 72=Return, 112=Kit Master Cartons, 46=SHIP, 134=VEHICLE_TYPE, 121=SGTIN, 135=VEHICLE_ID, 45=DE-COM, 113=Bulk Cartons , 136=VEHICLE_COLOR, 131=CARRIER, 52=Invoice Number, 101=File, 114=Product Master Cartons , 81=GLN, 42=Kit, 53=Shipping Number, 47=RECEIVE, 111=Pallet, 133=SHIPMENT_TYPE, 71=Sale, 43=DIS, 116=Kits, 21=en, 123=SSCC, 22=es, 117=Products, 44=COM, 132=EXPECTED_DELIVERY_DATE, 73=Transfer, 51=Purchase Order Number}"

I modify the response as given in tempMap data using below javascript code.

var map=(str.replace(/=/gi,"\"= \"").replace(/,/gi,"\",\"").replace(/=/gi,":"));
map="{\""+map.substring(2,(map.length)-1)+"\"}"

But I could not get the output by passing key value. I don’t want to use any other third party to do this.

  • 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-03T06:09:39+00:00Added an answer on June 3, 2026 at 6:09 am

    You have almost got that right.

    Adding whitespace characters to second replace

    var map=(str.replace(/=/gi,"\"= \"").replace(/,\s*/gi,"\",\"").replace(/=/gi,":"));
    map="{\""+map.substring(2,(map.length)-1)+"\"}";
    

    So that later you could execute

    map = JSON.parse(map);
    

    or

    map = eval("(" + map + ")");
    

    if you are dealing with browsers that do not support JSON.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using using Bingmap api, want to use static map i am using
I want to get Javascript data in another page and use it in an
I am a new android app developer and i want to use google map
I have a header file. In this header I want to use a map
I want to use a C++ map structure, such as map<vector<DFSCode>, vector<PDB>> candidate ,
I am new to the structure map but i want to use it in
I want to place markers on the map. I want to use the standard
For instance, if I want to map property Title I use: > Map(x =>
i want use some data from a website with web service. i have a
I have a google map in a page (Using the Javascript API v3) the

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.