Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
86 views
in Technique[技术] by (71.8m points)

javascript - How can I remove last 1 in json?

I am using an api and by that I am getting this response

{
"categories": [
[
  "Related Queries",
  [
    {
      "value": "tower",
      "formInput": "tower"
    },
    {
      "value": "erection",
      "formInput": "erection"
    },
    {
      "value": "police protection",
      "formInput": "police%20protection"
    },
    {
      "value": "to provide police protection",
      "formInput": "to%20provide%20police%20protection"
    },
    {
      "value": "phone tower",
      "formInput": "phone%20tower"
    }
  ]
],
[
  "Document Types",
  [
    {
      "value": "All",
      "formInput": "jio",
      "selected": true
    },
    {
      "value": "Laws",
      "formInput": "jio+doctypes:laws"
    },
    {
      "value": "Judgments",
      "formInput": "jio+doctypes:judgments"
    },
    {
      "value": "Highcourts",
      "formInput": "jio+doctypes:highcourts"
    },
    {
      "value": "HC & SC",
      "formInput": "jio+doctypes:supremecourt,scorders,highcourts"
    }
  ]
],
[
  "Courts",
  [
    {
      "value": "chennai",
      "formInput": "jio+doctypes:chennai",
      "selected": false
    },
    {
      "value": "kerala",
      "formInput": "jio+doctypes:kerala",
      "selected": false
    },
    {
      "value": "cat_delhi",
      "formInput": "jio+doctypes:cat_delhi",
      "selected": false
    },
    {
      "value": "bombay",
      "formInput": "jio+doctypes:bombay",
      "selected": false
    },
    {
      "value": "delhi",
      "formInput": "jio+doctypes:delhi",
      "selected": false
    },
    {
      "value": "supremecourt",
      "formInput": "jio+doctypes:supremecourt",
      "selected": false
    },
    {
      "value": "patna",
      "formInput": "jio+doctypes:patna",
      "selected": false
    },
    {
      "value": "patna_orders",
      "formInput": "jio+doctypes:patna_orders",
      "selected": false
    },
    {
      "value": "jodhpur",
      "formInput": "jio+doctypes:jodhpur",
      "selected": false
    },
    {
      "value": "madhyapradesh",
      "formInput": "jio+doctypes:madhyapradesh",
      "selected": false
    }
  ]
],
[
  "Authors",
  [
    {
      "value": "K Venkataswami",
      "formInput": "jio+author:K Venkataswami"
    },
    {
      "value": "S Sanyal",
      "formInput": "jio+author:S Sanyal"
    },
    {
      "value": "S.C.Sharma",
      "formInput": "jio+author:S.C.Sharma"
    }
  ]
],
[
  "Years",
  [
    {
      "value": 2015,
      "formInput": "jio+fromdate:1-1-2015+todate:31-12-2015"
    },
    {
      "value": 2016,
      "formInput": "jio+fromdate:1-1-2016+todate:31-12-2016"
    },
    {
      "value": 2014,
      "formInput": "jio+fromdate:1-1-2014+todate:31-12-2014"
    },
    {
      "value": 2019,
      "formInput": "jio+fromdate:1-1-2019+todate:31-12-2019"
    },
    {
      "value": 2011,
      "formInput": "jio+fromdate:1-1-2011+todate:31-12-2011"
    }
  ]
]
],
  "docs": [
{
  "title": "M/S. Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 22 January, 2016",
  "covertitles": [
    
  ],
  "numcites": 2,
  "numcitedby": 0,
  "url": "http://judis.nic.in/Judis_Chennai/list_new2.asp?FileName=259280",
  "headline": "Madras High Court 
 M/S. Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 22 January, 2016          

 
IN THE HIGH ... Reliance <b>Jio</b> Infocomm Limited
having its circle office at 
A1 Tower, 8th Floor,
89-90, Dr.Radhakrishnan Salai,
Mylapore, 
Chennai",
  "docsize": 3785,
  "tid": 90453177,
  "covertids": [
    
  ],
  "doctype": 24,
  "publishdate": "2016-01-22",
  "firstname": null,
  "secondname": null,
  "lastname": null,
  "fragment": true,
  "docsource": "Madras High Court",
  "covers": [
    
  ]
},
{
  "title": "M/S.Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 29 January, 2016",
  "covertitles": [
    
  ],
  "numcites": 1,
  "numcitedby": 0,
  "url": "http://judis.nic.in/Judis_Chennai/list_new2.asp?FileName=260428",
  "headline": "Madras High Court 
 M/S.Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 29 January, 2016          

 
IN THE HIGH ... Reliance <b>Jio</b> Infocomm Limited,
Having its Circle Office at
A1 Tower, 8th Floor,
89-90, Dr.Radhakrishnan Salai,
Malpore Chennai",
  "docsize": 3458,
  "tid": 52215865,
  "covertids": [
    
  ],
  "doctype": 24,
  "publishdate": "2016-01-29",
  "firstname": null,
  "secondname": null,
  "lastname": null,
  "fragment": true,
  "docsource": "Madras High Court",
  "covers": [
    
  ]
},
{
  "title": "M/S.Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 26 August, 2015",
  "covertitles": [
    
  ],
  "numcites": 1,
  "numcitedby": 0,
  "url": "http://judis.nic.in/Judis_Chennai/list_new2.asp?FileName=239394",
  "headline": "Madras High Court 
 M/S.Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 26 August, 2015          

 
IN THE HIGH ... Reliance <b>Jio</b> Infocomm Limited
Having its Circle Office at
A1 Tower, 8th Floor,
89-90, Dr.Radhakrishnan Salai,
Mylapore, Chennai",
  "docsize": 3599,
  "tid": 121257329,
  "covertids": [
    
  ],
  "doctype": 24,
  "publishdate": "2015-08-26",
  "firstname": null,
  "secondname": null,
  "lastname": null,
  "fragment": true,
  "docsource": "Madras High Court",
  "covers": [
    
  ]
},
{
  "title": "M/S Reliance <b>Jio</b> Infocomm Ltd. vs The State Of Bihar & Ors on 10 August, 2015",
  "covertitles": [
    
  ],
  "numcites": 2,
  "numcitedby": 0,
  "url": null,
  "headline": "Patna High Court - Orders 
 M/S Reliance <b>Jio</b> Infocomm Ltd. vs The State Of Bihar &amp; Ors on 10 August ... Case No.7591 of 2015
======================================================
1. M/s Reliance <b>JIO</b> Infocomm Ltd., a companywithin the meaning of the
 Companies",
  "docsize": 7026,
  "tid": 22796076,
  "covertids": [
    
  ],
  "doctype": 45,
  "publishdate": "2015-08-10",
  "firstname": null,
  "secondname": null,
  "lastname": null,
  "fragment": true,
  "docsource": "Patna High Court - Orders",
  "covers": [
    
  ]
},
{
  "title": "M/S.Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 26 August, 2015",
  "covertitles": [
    
  ],
  "numcites": 1,
  "numcitedby": 0,
  "url": "http://judis.nic.in/Judis_Chennai/list_new2.asp?FileName=239260",
  "headline": "Madras High Court 
 M/S.Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 26 August, 2015          

 
IN THE HIGH ... Reliance <b>Jio</b> Infocomm Limited
Having its Circle Office at
A1 Tower, 8th Floor,
89-90, Dr.Radhakrishnan Salai,
Mylapore, Chennai",
  "docsize": 3547,
  "tid": 17100782,
  "covertids": [
    
  ],
  "doctype": 24,
  "publishdate": "2015-08-26",
  "firstname": null,
  "secondname": null,
  "lastname": null,
  "fragment": true,
  "docsource": "Madras High Court",
  "covers": [
    
  ]
},
{
  "title": "M/S.Reliance <b>Jio</b> Inforcomm ... vs The Assistant Engineer on 26 August, 2015",
  "covertitles": [
    
  ],
  "numcites": 1,
  "numcitedby": 0,
  "url": "http://judis.nic.in/Judis_Chennai/list_new2.asp?FileName=239488",
  "headline": "Madras High Court 
 M/S.Reliance <b>Jio</b> Inforcomm ... vs The Assistant Engineer on 26 August, 2015          

 
IN THE HIGH COURT ... Reliance <b>Jio</b> Inforcomm Limited,
having Circle Office at A1 Tower,
8th Floor, 89-90, Dr.Radhakrishnan Salai,
Mylapore, Chennai",
  "docsize": 4056,
  "tid": 76372287,
  "covertids": [
    
  ],
  "doctype": 24,
  "publishdate": "2015-08-26",
  "firstname": null,
  "secondname": null,
  "lastname": null,
  "fragment": true,
  "docsource": "Madras High Court",
  "covers": [
    
  ]
},
{
  "title": "M/S.Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 15 April, 2015",
  "covertitles": [
    
  ],
  "numcites": 1,
  "numcitedby": 0,
  "url": "http://judis.nic.in/judis_chennai/qrydisp.aspx?filename=77566",
  "headline": "Madras High Court 
 M/S.Reliance <b>Jio</b> Infocomm ... vs The Inspector Of Police on 15 April, 2015         

  

   

 
 
 BEFORE THE MADURAI ... 6885 of 2015:

M/s.Reliance <b>Jio</b> Infocomm Limited,
having its Circle Office at A1 Tower, 8th Floor",
  "docsize": 5103,
  "tid": 187432957,
  "covertids": [
    
  ],
  "doctype": 24,
  "publishdate": "2015-04-15",
  "firstname": null,
  "secondname": null,
  "lastname": null,
  "fragment": true,
  "docsource": "Madras High Court",
  "covers": [
    
  ]
},
{
  "title": "M/S.Reliance <b>Jio</b> Infocomm ... vs The Assistant Engineer on 19 March, 2015",
  "covertitles": [
    
  ],
  "numcites": 1,
  "numcitedby": 0,
  "url":

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Quick and dirty, I would do as follows within the PHP code

$rest = substr($rest, 0, -1);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...