JSFiddle - React, Tailwind, and code Playground

by Yair Nevet

HTML

<script src="//cdn.jsdelivr.net/jquery.cookie/1.4.0/jquery.cookie.js"></script>

JavaScript

//First we make sure to remove old values because this an example only
$.cookie("products", null);

var myProducts ='[{"productName":"31","description":"this is a red item","quantity":"","price":"15"},{"productName":"35","description":"this color is blue","quantity":"","price":"600"}]';

//Set the cookie
$.cookie("products", myProducts);

var stringJson = $.cookie('products');

//Parse the cookie value to JSON object
var jsonArray = JSON.parse(stringJson);

//print products
for(obj in jsonArray)
{
    console.log(jsonArray[obj].productName);
}