Showing posts with label JSON. Show all posts
Showing posts with label JSON. Show all posts

Monday 31 August 2020

Sorting Json value using Javascript / jQuery

Sort by updated date

<script>

var data = "[

  {

    "_id": "5efd566ab3e22f002484bbb0",

    "first_name": "Jaydip",

    "last_name": "Kansagra",

    "rate": "0",

    "createdAt": "2020-07-02T03:37:14.808Z",

    "updatedAt": "2020-07-02T03:37:14.808Z"

  },

  {

    "_id": "5f16d3933fdf4a0024b7a2f8",

    "first_name": "Jaydip",

    "last_name": "Kansagra",

    "rate": "5",

    "createdAt": "2020-07-21T11:37:55.310Z",

    "updatedAt": "2020-07-21T11:37:55.310Z"

  },

  {

    "_id": "5f3bc286436d850024a2b574",

    "first_name": "Jaydip",

    "last_name": "Kansagra",

    "rate": "3",

    "createdAt": "2020-08-18T11:59:02.825Z",

    "updatedAt": "2020-08-18T11:59:02.825Z"

  }

]";

theme.blend_Obj = data;

theme.blend_Obj.sort((a, b) => (a.updatedAt > b.updatedAt) ? 1 : -1)

</script>

==================================

Sort by Rate (integer value)

<script>

topRates = [...theme.blend_Obj]

topRates.sort((a, b) => (parseInt(a.rate) < parseInt(b.rate)) ? 1 : -1);


</script>

Tuesday 2 January 2018

How to install extensions in php 7 cent os


Install extensions in php 7 cent os follow these steps

1. curl 'https://setup.ius.io/' -o setup-ius.sh
2. sudo bash setup-ius.sh
3. sudo yum install -y mod_php70w php70w-cli php70w-mysqlnd php70w-json php70w-gd php70w-dom php70w-simplexml php70w-mcrypt php70w-intl httpd mysql-server git

Wednesday 4 May 2016

Convert PHP, Magento, Joomla, Codeigniter, Cake PHP, Wordpress XML to JSON, XML to Array, JSON to Array

Convert PHP, Magento, Joomla, Codeigniter, Cake PHP, Wordpress XML to JSON, XML to Array, JSON to Array is very difficult task for some people. But, in PHP, believe me it’s very easy. One line of code each! Don’t believe? Just check out the code below and test it yourself!


$xml = simplexml_load_string($xmldata);
$json = json_encode($xml);
$array = json_decode($json,true);