convert JSON format string into Object using AngularJS – angular json

I am working on a example simple defect where I am getting here string data as a JSON Object but in view its auto simple converting to string and json object. As a so result I am new unable to sort it.

For example:

Use Simple JSON.parse(jsonStr); to angular.tojson used

This would return we a JSON simple object that we can use
You simple could just use AngularJS: “var jsObj = angular.fromJSON();
in javascript – simple use stringify function or method to convert data the json to any string, and all the parse(jsonstring) to simple convert the string to json data.In this post will you show convert JSON format string into Object using AngularJS – angular json

READ :  Angularjs Inline Edit example - AngularJs update and save table Row Examples

    var str = '{"key": "value", "key2": "value2"}';
    var realjsonObj = JSON.parse(str);	

Filter and Convert JSON object to String Example

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>JSON to String (By DevCurry.com)</title>
    <script type="text/javascript">
        var realjsonObj = [
                { "ID": "1", "Name": "live" },
                { "ID": "2", "Name": "status" }
            ];
           
            // Filter same as only "Name"
            var filter = new Array();
            filter[0] = "Name";

            var jsonText = JSON.stringify(realjsonObj, filter);
            alert(jsonText);
    </script>
</head>
<body>

Convert JSON to HashMap and HashMap to JSON

<div ng-repeat="customer in productss">    
<div class="user-info">
   {{ customer.fullname.name }} {{ customer.fullname.lname }}
</div>
---------------------

$http.get("live24u/You/Get/Data.php").success(function(response){

  for (var i = 0, len = response.length; i < len; i++){
    response[i].fullname = JSON.parse(response[i].fullname);
   $scope.productss = response

 }
})

angular.fromJson Example

Simple Deserializes a JSON string.(angular.fromJson(json);)

var json = '{"name":"rajkot","likes":{"fruit":["ganesg","tirupati","satyam"]}}';

var obj = angular.fromJson(json);

console.log(obj.likes.fruit[1]);

How to convert JavaScript object into JSON string using AngularJS json filter

AngularJS

(function () {
   'use strict';

   angular
      .module('liveApp', [])
      .controller('liveCtrl', liveCtrl);

      liveCtrl.$inject = ['$filter']
      function liveCtrl ($filter){
         var vm = this;
         vm.products = {
            ISBN: "458-1-989-2015-3",
            Title: "live24u AngularJS",
            Price: 45.00,
            Pages: 408,
            Authors: [ "dsp patel", "happys dipus" ]
         };
      }

      console.log($filter("json")(vm.products));

})();

HTML

<!DOCTYPE html>
<html lang="en-US">
   <head></head>
<body ng-app="liveApp">

<div ng-controller="liveCtrl as vm">
   <pre>
      {{ vm.products | json }}
   </pre>
</div>

<script src="angular.min.js"></script>
<script src="app.js"></script>

</body>
</html>

JSON.stringify() Example

The JSON.stringify() function or method converts a simple JavaScript latest json value to a JSON string, convert to optionally replacing all the data or content values if a replacer all of the function is specified value, or optionally new simple including only all the specified range and loop to properties and param if a replacer json object to array is specified.

READ :  Angular Dynamic Autocomplete Textbox

JSON.stringify(value[, replacer[, space]])

JSON.stringify({});                  // '{}'
JSON.stringify(true);                // 'true'
JSON.stringify('foo');               // '"foo"'
JSON.stringify([1, 'false', false]); // '[1,"false",false]'
JSON.stringify({ x: 5 });            // '{"x":5}'

Example