Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community that shares solutions with each other.

If you think you have something to add here.

you are welcome with your fresh ideas - List Articles

JavaScript - how to convert json text to dictionary (map / plain object) variable?

0 contributions
13 points

In first versions of JavaScript it was possiblility to create plain object and make 5 operations on them: add, update, check, delete and iterate items (called properties). It was called prototyping process. This way programmers used objects as Map (Dictionary or associate array) to solve some missing features. ECMAScript 2015 (6th Edition) introduced Map type.

In JavaScript it is possible to convert json text to plain object variable in following way.

1. JSON.parse example

// ONLINE-RUNNER:browser;

var json = '{"key 1":"value 1", "key 2":"value 2", "key 3":"value 3"}';
var dictionary = JSON.parse(json);

console.log(dictionary['key 1']);
console.log(dictionary['key 2']);
console.log(dictionary['key 3']);

Note: abowe example is nothing more like deserialzaion of json with plain object inside.

See also

  1. JavaScript - deserialize json to object
  2. JavaScript - how to convert json to dictionary from server response?
0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more