title: Codeigniter - Encode, Decode JSON
body: <p>There are two tables such as Package and PackageService. The main tables are Package Table. I joined these tables between package.packageService = packageService.packageServiceId. I want to hold some data in Package Table with JSON using id. I have an edit page. I want to when I edit some package, I can choose some package multiple features with checkbox afterthat I can show these features on Package View and Package Edit View. How can I do this with JSON clearly?</p>
  
  <p>My Model:</p>
  
  <pre><code>public function packages()
  
      {
  
          $this-&gt;db-&gt;select_max('packageId', 'MaxPackageId');
          $this-&gt;db-&gt;select('IF(packageParent = 0, packageId, packageParent) as parent', FALSE);
          $this-&gt;db-&gt;from('package');
          $this-&gt;db-&gt;group_by('parent');
  
          $subquery = $this-&gt;db-&gt;get_compiled_select();
          $this-&gt;db-&gt;reset_query();
          $this-&gt;db-&gt;select('package.*, packageService.*');
          $this-&gt;db-&gt;from('package');
          $this-&gt;db-&gt;join("($subquery) t1","t1.MaxPackageId = package.packageId");
          $this-&gt;db-&gt;join('packageService', 'package.packageService = packageService.packageServiceId', 'LEFT');
  
          $query = $this-&gt;db-&gt;get();
  
          return $query-&gt;result();
  
  
  
      }
  </code></pre>
  
  <p>Package View:</p>
  
  <pre><code>&lt;section id="main-content"&gt;
      &lt;section class="wrapper site-min-height"&gt;
          &lt;!-- page start--&gt;
          &lt;div class="row"&gt;
              &lt;!--price start--&gt;
              &lt;div class="text-center feature-head"&gt;
                  &lt;h1&gt; PACKAGES &lt;/h1&gt;
                  &lt;p&gt;Choose Your Special Package Plan. &lt;/p&gt;
              &lt;/div&gt;
  
              &lt;?php foreach($packs as $get) { ?&gt;
                  &lt;div class="col-lg-3 col-sm-3"&gt;
                      &lt;div class="pricing-table &lt;?php if ($get-&gt;packageNameEn == 'Platinum') { echo 'most-popular'; } ?&gt;"&gt;
                          &lt;div class="pricing-head"&gt;
                              &lt;h1&gt; &lt;?php echo $get-&gt;packageNameEn; ?&gt; &lt;/h1&gt;
                              &lt;h5&gt;&lt;del&gt;€ &lt;?php echo $get-&gt;packagePrice ?&gt;&lt;/del&gt;&lt;/h5&gt;
                              &lt;h2&gt;&lt;span class="note"&gt;€&lt;/span&gt; &lt;?php echo $get-&gt;packagePriceCut ?&gt; &lt;/h2&gt;
  
                          &lt;/div&gt;
                          &lt;ul class="list-unstyled"&gt;
                              // I want to show package features with JSON here &lt;?php echo $get-&gt;packageServiceNameEn ?&gt;
                          &lt;/ul&gt;
                          &lt;div class="price-actions"&gt;
                              &lt;a class="btn" href="javascript:;"&gt;Get Now&lt;/a&gt;
                              &lt;a class="btn" href="&lt;?php echo base_url("package/edit/$get-&gt;packageId"); ?&gt;"&gt;Edit&lt;/a&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;?php } ?&gt;
          &lt;/div&gt;
          &lt;!-- page end--&gt;
      &lt;/section&gt;
  &lt;/section&gt;
  &lt;!--main content end--&gt;
  </code></pre>