Json not getting data from list - json

I am having a problem with reading json data. I have tried a few methods but came up short. Any help is welcome. Here is the code:
Its corrected with the whole file now.
"gallery": {
"106x100": [
"106x100-0.jpeg",
"106x100-1.jpeg",
"106x100-2.jpeg",
"106x100-3.jpeg",
"106x100-4.jpeg",
"106x100-5.jpeg",
"106x100-6.jpeg",
"106x100-7.jpeg",
"106x100-8.jpeg",
"106x100-9.jpeg",
"106x100-10.jpeg",
"106x100-11.jpeg",
"106x100-12.jpeg",
"106x100-13.jpeg",
"106x100-14.jpeg",
"106x100-15.jpeg",
"106x100-16.jpeg"
],
"190x100": [
"190x100-0.jpeg",
"190x100-1.jpeg",
"190x100-2.jpeg",
"190x100-3.jpeg",
"190x100-4.jpeg",
"190x100-5.jpeg",
"190x100-6.jpeg",
"190x100-7.jpeg",
"190x100-8.jpeg",
"190x100-9.jpeg",
"190x100-10.jpeg",
"190x100-11.jpeg",
"190x100-12.jpeg",
"190x100-13.jpeg",
"190x100-14.jpeg",
"190x100-15.jpeg",
"190x100-16.jpeg"
]
},
},

Your json's format is wrong.
Here is the correct format:
{"190x100": [
"190x100-0.jpeg",
"190x100-1.jpeg",
"190x100-2.jpeg",
"190x100-3.jpeg",
"190x100-4.jpeg",
"190x100-5.jpeg",
"190x100-6.jpeg",
"190x100-7.jpeg",
"190x100-8.jpeg",
"190x100-9.jpeg",
"190x100-10.jpeg",
"190x100-11.jpeg",
"190x100-12.jpeg",
"190x100-13.jpeg",
"190x100-14.jpeg",
"190x100-15.jpeg",
"190x100-16.jpeg"
]}
PS: Read that you are using java. You can then try this:
String jsonString = "{"+json+"}"; //pass json here if you are getting it in that format.
JSONObject jsonObject = new JSONObject(jsonString);
JSONObject newJSON = jsonObject.getJSONObject("gallery");
System.out.println(newJSON.toString());
Again the format is wrong. Here is the format:
{"gallery": {
"106x100": [
"106x100-0.jpeg",
"106x100-1.jpeg",
"106x100-2.jpeg",
"106x100-3.jpeg",
"106x100-4.jpeg",
"106x100-5.jpeg",
"106x100-6.jpeg",
"106x100-7.jpeg",
"106x100-8.jpeg",
"106x100-9.jpeg",
"106x100-10.jpeg",
"106x100-11.jpeg",
"106x100-12.jpeg",
"106x100-13.jpeg",
"106x100-14.jpeg",
"106x100-15.jpeg",
"106x100-16.jpeg"
],
"190x100": [
"190x100-0.jpeg",
"190x100-1.jpeg",
"190x100-2.jpeg",
"190x100-3.jpeg",
"190x100-4.jpeg",
"190x100-5.jpeg",
"190x100-6.jpeg",
"190x100-7.jpeg",
"190x100-8.jpeg",
"190x100-9.jpeg",
"190x100-10.jpeg",
"190x100-11.jpeg",
"190x100-12.jpeg",
"190x100-13.jpeg",
"190x100-14.jpeg",
"190x100-15.jpeg",
"190x100-16.jpeg"
]
}
}

Related

Send JSON from MySQL query in NodeJS?

Currently my NodeJS code sends JSON back in the following format;
{"data":
[
{"audioname":"mytalk.m4a","name":"Josie ","email":"josie#gmail.com"},
{"audioname":"mytalk40.m4a","name":"Jessie James","email":"jesse#gmail.com"},
{"audioname":"mytalk.m4a","name":"Joan Bologney","email":"joan#gmail.com"}
]
}
But I'd like to get rid of the "data" and send back just;
[
{"audioname":"mytalk.m4a","name":"Josie ","email":"josie#gmail.com"},
{"audioname":"mytalk40.m4a","name":"Jessie James","email":"jesse#gmail.com"},
{"audioname":"mytalk.m4a","name":"Joan Bologney","email":"joan#gmail.com"}
]
Here's the query;
query = mysql.format(query);
connection.query(query,function(err,data){
if(err) {
res.json({"Error" : true, "Message" : "Error executing MySQL query"});
} else {
res.json({data});
}
});
If the object shown above is available though the data variable, we can pass only the data array by using:
res.json(data.data);
Where the second data references to the data array in the data variable.
Small example:
const data = {"data": [{"audioname":"mytalk.m4a","name":"Josie ","email":"josie#gmail.com"}, {"audioname":"mytalk40.m4a","name":"Jessie James","email":"jesse#gmail.com"}, {"audioname":"mytalk.m4a","name":"Joan Bologney","email":"joan#gmail.com"} ] };
console.log(data.data);
Removing the inner brackets seemed to work;
res.json(data);

Get array from json in Bigquery

I'm trying to get the data from a JSON in BigQuery. This JSON is Stored in a one-column table.
So far, I've been able to get only the "variables" array, with the following:
Select JSON_QUERY_ARRAY(Column1, '$.sessions[0].variables') FROM Table
How can I get the other values/arrays (sessionMessage and events)? I can't make it work..
I've tried with:
JSON_VALUE(Column1, '$.sessions[0].conversation')
JSON_QUERY_ARRAY(Column1, '$.sessions[0].sessionMessages')
But I get only empty values (The original json has values inside this arrays..)
{
"fromDate":"2020-04-10T23:47:17.161Z",
"pageRows":151,
"sessions":[
{
"variables":[],
"sessionDate":"2020-04-10T23:47:17.161Z",
"botMessages":2,
"userHasTalked":"true",
"topics":[
"TOPIC1"
],
"sessionId":"WXXXSXSXSXXXQ_2020-01-00T23:47:17.161Z",
"platformContactId":"XXXXXXX-XXXXXXX-XXXXXXXXXXXXXX",
"sessionMessages":[.....],
"queues":[
"QUEUE1",
"QUEUE2"
],
"customerId":"SSDSDS",
"userMessages":2,
"operatorMessages":1,
"sessionMessagesQty":2,
"sessionStartingCause":"Organic",
"channelId":"IDCHANEL",
"conversation":"https://url.com",
"events":[.....]
}
],
"toDate":"2020-04-10T23:47:17.161Z",
"hasMore":true,
"pageToken":"XXXXXXXXXXXXXX"
}
There is nothing wrong with the function and JSONPath that you used, but your sample JSON file has some unexpected thing, like [.....], removing/replacing those and query below works fine:
WITH a as (select
"""
{
"fromDate":"2020-04-10T23:47:17.161Z",
"pageRows":151,
"sessions":[
{
"variables":[],
"sessionDate":"2020-04-10T23:47:17.161Z",
"botMessages":2,
"userHasTalked":"true",
"topics":[
"TOPIC1"
],
"sessionId":"WXXXSXSXSXXXQ_2020-01-00T23:47:17.161Z",
"platformContactId":"XXXXXXX-XXXXXXX-XXXXXXXXXXXXXX",
"sessionMessages":[1,2,3],
"queues":[
"QUEUE1",
"QUEUE2"
],
"customerId":"SSDSDS",
"userMessages":2,
"operatorMessages":1,
"sessionMessagesQty":2,
"sessionStartingCause":"Organic",
"channelId":"IDCHANEL",
"conversation":"https://url.com",
"events":[],
}
],
"toDate":"2020-04-10T23:47:17.161Z",
"hasMore":true,
"pageToken":"XXXXXXXXXXXXXX"
}
""" data)
SELECT JSON_VALUE(data, '$.sessions[0].conversation'),
JSON_QUERY_ARRAY(data, '$.sessions[0].sessionMessages')
FROM a;

Multilevel Complex Nested Json Using Spark SQL

I have a specific requirement to convert some related tables data in nested json like below by using Spark SQL. I have achieved it with Scala but not getting it resolved in Spark SQL.
{
"REPORTING_CARRIER":"9E",
"DISTANCE":"3132",
"ORIGIN_STATE_NM":"Pennsylvania",
"QUARTER":"2",
"YEAR":"2017",
"ITIN_GEO_TYPE":"2",
"BULK_FARE":"0",
"ORIGIN":"ABE",
"ORIGIN_AIRPORT_ID":"10135",
"ITIN_FARE":"787",
"ORIGIN_CITY_MARKET_ID":"30135",
"ROUNDTRIP":"1",
"Market":[
{
"MKT_DISTANCE":"1566",
"MKT_BULK_FARE":"0",
"MKT_NO_OF_CPNS":"2",
"MKT_DEST_STATE_NM":"Texas",
"MKT_OP_CARR_GRP":"9E:DL",
"MKT_TK_CARR_GRP":"DL:DL",
"MKT_MILES_FLOWN":"1566",
"MKT_AIRPORT_GROUP":"ABE:ATL:SAT",
"MKT_FARE_AMT":"393.5",
"MKT_ORIG_STATE_NM":"Pennsylvania",
"MKT_DEST_ARPT_CITY_NM":"33214",
"MKT_RPTG_CARR_NM":"9E",
"MKT_DEST":"SAT",
"MKT_DEST_CNTRY":"US",
"MKT_ORIG_CNTRY":"US",
"Coupon":[
{
"CPN_STATE_NM":"Georgia",
"CPN_DEST":"ATL",
"CPN_TKT_CARR_NM":"DL",
"TRIP_BREAK":"",
"CPN_MKT_ORIG_ARPT_NM":"10135",
"CLASS_OF_SVC":"X",
"CPN_TKT_NBR":"2017245",
"CPN_DEST_CITY_MKT_NM":"30397",
"CPN_DISTANCE":"692",
"SEQ_NUM":"1",
"ITIN_GEO_TYPE":"2",
"CPN_RPTG_CARR_NM":"9E",
"COUPON_GEO_TYPE":"2",
"CPN_ORIG_STATE_NM":"Pennsylvania",
"CPN_OPERG_CARR_NM":"9E",
"CPN_ORIG":"ABE",
"CPN_PASSENGERS":"1",
"COUPON_TYPE":"A",
"CPN_DEST_ARPT_NM":"10397",
"CPN_MKT_ORIG_CITY_NM":"30135",
"CPN_DEST_CNTRY":"US",
"CPN_MKT_ID":"201724501",
"CPN_ORIG_CNTRY":"US"
},
{
"CPN_STATE_NM":"Texas",
"CPN_DEST":"SAT",
"CPN_TKT_CARR_NM":"DL",
"TRIP_BREAK":"X",
"CPN_MKT_ORIG_ARPT_NM":"10397",
"CLASS_OF_SVC":"X",
"CPN_TKT_NBR":"2017245",
"CPN_DEST_CITY_MKT_NM":"33214",
"CPN_DISTANCE":"874",
"SEQ_NUM":"2",
"ITIN_GEO_TYPE":"2",
"CPN_RPTG_CARR_NM":"9E",
"COUPON_GEO_TYPE":"2",
"CPN_ORIG_STATE_NM":"Georgia",
"CPN_OPERG_CARR_NM":"DL",
"CPN_ORIG":"ATL",
"CPN_PASSENGERS":"1",
"COUPON_TYPE":"A",
"CPN_DEST_ARPT_NM":"14683",
"CPN_MKT_ORIG_CITY_NM":"30397",
"CPN_DEST_CNTRY":"US",
"CPN_MKT_ID":"201724501",
"CPN_ORIG_CNTRY":"US"
}
],
"MKT_ITIN_ID":"2017245",
"MKT_OPERG_CARR_NM":"99",
"MKT_DEST_ARPT_NM":"14683",
"MKT_ORIG_ARPT_NM":"ABE",
"MKT_ITIN_GEO_TYPE":"2",
"MKT_PASSENGERS":"1",
"MKT_ID":"201724501",
"MKT_TKT_CARR_NM":"DL"
},
{
"MKT_DISTANCE":"1566",
"MKT_BULK_FARE":"0",
"MKT_NO_OF_CPNS":"2",
"MKT_DEST_STATE_NM":"Pennsylvania",
"MKT_OP_CARR_GRP":"DL:DL",
"MKT_TK_CARR_GRP":"DL:DL",
"MKT_MILES_FLOWN":"1566",
"MKT_AIRPORT_GROUP":"SAT:ATL:ABE",
"MKT_FARE_AMT":"393.5",
"MKT_ORIG_STATE_NM":"Texas",
"MKT_DEST_ARPT_CITY_NM":"30135",
"MKT_RPTG_CARR_NM":"9E",
"MKT_DEST":"ABE",
"MKT_DEST_CNTRY":"US",
"MKT_ORIG_CNTRY":"US",
"Coupon":[
{
"CPN_STATE_NM":"Georgia",
"CPN_DEST":"ATL",
"CPN_TKT_CARR_NM":"DL",
"TRIP_BREAK":"",
"CPN_MKT_ORIG_ARPT_NM":"14683",
"CLASS_OF_SVC":"X",
"CPN_TKT_NBR":"2017245",
"CPN_DEST_CITY_MKT_NM":"30397",
"CPN_DISTANCE":"874",
"SEQ_NUM":"3",
"ITIN_GEO_TYPE":"2",
"CPN_RPTG_CARR_NM":"9E",
"COUPON_GEO_TYPE":"2",
"CPN_ORIG_STATE_NM":"Texas",
"CPN_OPERG_CARR_NM":"DL",
"CPN_ORIG":"SAT",
"CPN_PASSENGERS":"1",
"COUPON_TYPE":"A",
"CPN_DEST_ARPT_NM":"10397",
"CPN_MKT_ORIG_CITY_NM":"33214",
"CPN_DEST_CNTRY":"US",
"CPN_MKT_ID":"201724503",
"CPN_ORIG_CNTRY":"US"
},
{
"CPN_STATE_NM":"Pennsylvania",
"CPN_DEST":"ABE",
"CPN_TKT_CARR_NM":"DL",
"TRIP_BREAK":"X",
"CPN_MKT_ORIG_ARPT_NM":"10397",
"CLASS_OF_SVC":"X",
"CPN_TKT_NBR":"2017245",
"CPN_DEST_CITY_MKT_NM":"30135",
"CPN_DISTANCE":"692",
"SEQ_NUM":"4",
"ITIN_GEO_TYPE":"2",
"CPN_RPTG_CARR_NM":"9E",
"COUPON_GEO_TYPE":"2",
"CPN_ORIG_STATE_NM":"Georgia",
"CPN_OPERG_CARR_NM":"DL",
"CPN_ORIG":"ATL",
"CPN_PASSENGERS":"1",
"COUPON_TYPE":"A",
"CPN_DEST_ARPT_NM":"10135",
"CPN_MKT_ORIG_CITY_NM":"30397",
"CPN_DEST_CNTRY":"US",
"CPN_MKT_ID":"201724503",
"CPN_ORIG_CNTRY":"US"
}
],
"MKT_ITIN_ID":"2017245",
"MKT_OPERG_CARR_NM":"DL",
"MKT_DEST_ARPT_NM":"10135",
"MKT_ORIG_ARPT_NM":"SAT",
"MKT_ITIN_GEO_TYPE":"2",
"MKT_PASSENGERS":"1",
"MKT_ID":"201724503",
"MKT_TKT_CARR_NM":"DL"
}
],
"NO_OF_CPNS":"4",
"ORIGIN_COUNTRY":"US",
"ITIN_ID":"2017245",
"PASSENGERS":"1",
"MILES_FLOWN":"3132"
}
You can use the from_json() helper function within the select() Dataset API call, to extract or decode data's attributes and values from a JSON string into a DataFrame as columns, dictated by a schema.
example, given the following json { "reporting_carrier": "A", "market": { "value": 10 } }, stored in the rawJsonDf
case class MarketData (reporting_carrier: String, market_json: String)
val jsonSchema = new StructType()
.add("value", LongType)
rawJsonDf
.toDf("reporting_carrier","market")
.as[MarketData]
rawJsonDf
.select(from_json($"market_json", jsonSchema) as "market")
.filter($"market.value" > 5)
see this great tutorial by databricks for more info.

Unable to scrape the names from json response

There are around 966 names in the webpage with json content but with my script I'm getting only 10 out of them. I'm very new to json that is why I'can't figure out the mistake I'm making. How can I get all the names? I'm trying with the below code:
import requests
url = 'https://www.zebra.com/bin/zebra/partnersearch?inMiles=true&start=0&numRows=10&latitude=39.5500507&longitude=-105.7820674&sortOrder=asc&sortBy=distance&country=US&searchRadius=5000'
response = requests.get(url)
data = response.json()
for item in data:
print(item['name'])
Partial json content from that page is:
[{"id":"001i000001XR9dqAAD","website":"www.resortinternet.com","type":"partner","phoneNumber":"+1.970.262.3515","name":"Resortnet, LLC","logoPresent":"No","logoExtension":"","des":"Technology provider for destination resorts","translatedName":"ResortInternet","dbaName":"ResortInternet","PR":"NA","AN":"6244306","accountType":["Reseller"],"contentType":"parent","countries":["US"],"HSA":[],"countriesAndHsa":["US"],"premierSolutionPartner":false,"premierBusinessPartner":false,"solutionPartner":true,"businessPartner":false,"advancedSpecialistBarcodePrinterSupplies":false,"advancedSpecialistCardPrinters":false,"advancedSpecialistSupplies":false,"advancedSpecialistWirelessNetworks":false,"advancedSpecialistPrintEngines":false,"advancedSpecialistRfid":false,"specialistBarcodePrinterSupplies":false,"specialistCardPrinters":false,"specialistSupplies":false,"specialistWirelessNetworks":false,"specialistPrintEngines":false,"specialistRfid":false,"advancedRepairSpecialistLabelPrinter":false,"advancedRepairSpecialistCardPrinter":false,"advancedRepairSpecialistMobilePrinter":false,"advancedRepairSpecialistPrintEngine":false,"repairSpecialistLabelPrinter":false,"repairSpecialistCardPrinter":false,"repairSpecialistMobilePrinter":false,"repairSpecialistPrintEngine":false,"registeredResellerNoSpecialization":false,"pmiWraps":[{"programName":"Solution Partner","category":"Reseller","id":"001i000001XR9dqAAD_2","type":"pmiWrap","contentType":"child"}],"partnerLocations":[{"locationType":"Headquarters","addressLine1":"117 S 6th Ave.,","addressLine2":"PO Box 2718","city":"Frisco","state":"Colorado","zipCode":"80443","country":"United States","phone":"(970) 262-3515","fax":"(970) 668-9431","latlon":"39.5754576,-106.0952117","distance":16.8,"countryCode":"US","HSA":[],"id":"001i000001XR9dqAAD_0","type":"partnerLocation","contentType":"child"},{"locationType":"Primary Location","addressLine1":"117 S 6th Ave.,","city":"Frisco","state":"Colorado","zipCode":"80443","country":"United States","phone":"+1.970.262.3515","latlon":"39.5754576,-106.0952117","distance":16.8,"countryCode":"US","HSA":[],"id":"001i000001XR9dqAAD_1","type":"partnerLocation","contentType":"child"},{"locationType":"Address","addressLine1":"RESORTINTERNET\r2718:FRISCO:80443\r117 S 6TH AVERM UNIT 2","city":"Frisco","state":"Colorado","stateCode":"CO","zipCode":"80443","country":"United States","latlon":"39.5744309,-106.0975203","distance":16.9,"countryCode":"US","HSA":[],"id":"001i000001XR9dqAAD_100","type":"partnerLocation","contentType":"child"}],"verticalHierarchyWraps":[],"primaryLocation":{"locationType":"Headquarters","addressLine1":"117 S 6th Ave.,","addressLine2":"PO Box 2718","city":"Frisco","state":"Colorado","zipCode":"80443","country":"United States","phone":"(970) 262-3515","fax":"(970) 668-9431","latlon":"39.5754576,-106.0952117","distance":16.8,"countryCode":"US","HSA":
I don't think there's a problem with your code. If you check len(data) it returns 10, which means that the list of results contains only 10 (large) JSON objects.
Is there some reason you're expecting more than 10, or are you trying to access the name property of something inside each of these larger objects?
Your JSON is an array of objects, so when you loop through the data you aren't getting the array in your item variable but instead are getting the index of the array.
You can get the array by using the item variable as the index and once you have a reference to the array you can then read property objects such as name:
Like this:
for index in data:
item = data[index]
print(item['name'])
Here it is in JavaScript:
<script>
var data = [
{
"id":"001i000001XR9dqAAD",
"website":"www.resortinternet.com",
"type":"partner",
"phoneNumber":"+1.970.262.3515",
"name":"Resortnet, LLC",
"logoPresent":"No",
"logoExtension":"",
"des":"Technology provider for destination resorts",
"translatedName":"ResortInternet",
"dbaName":"ResortInternet",
"PR":"NA",
"AN":"6244306",
"accountType":[
"Reseller"
],
"contentType":"parent",
"countries":[
"US"
],
"HSA":[
],
"countriesAndHsa":[
"US"
],
"premierSolutionPartner":false,
"premierBusinessPartner":false,
"solutionPartner":true,
"businessPartner":false,
"advancedSpecialistBarcodePrinterSupplies":false,
"advancedSpecialistCardPrinters":false,
"advancedSpecialistSupplies":false,
"advancedSpecialistWirelessNetworks":false,
"advancedSpecialistPrintEngines":false,
"advancedSpecialistRfid":false,
"specialistBarcodePrinterSupplies":false,
"specialistCardPrinters":false,
"specialistSupplies":false,
"specialistWirelessNetworks":false,
"specialistPrintEngines":false,
"specialistRfid":false,
"advancedRepairSpecialistLabelPrinter":false,
"advancedRepairSpecialistCardPrinter":false,
"advancedRepairSpecialistMobilePrinter":false,
"advancedRepairSpecialistPrintEngine":false,
"repairSpecialistLabelPrinter":false,
"repairSpecialistCardPrinter":false,
"repairSpecialistMobilePrinter":false,
"repairSpecialistPrintEngine":false,
"registeredResellerNoSpecialization":false,
"pmiWraps":[
{
"programName":"Solution Partner",
"category":"Reseller",
"id":"001i000001XR9dqAAD_2",
"type":"pmiWrap",
"contentType":"child"
}
],
"partnerLocations":[
{
"locationType":"Headquarters",
"addressLine1":"117 S 6th Ave.,",
"addressLine2":"PO Box 2718",
"city":"Frisco",
"state":"Colorado",
"zipCode":"80443",
"country":"United States",
"phone":"(970) 262-3515",
"fax":"(970) 668-9431",
"latlon":"39.5754576,-106.0952117",
"distance":16.8,
"countryCode":"US",
"HSA":[
],
"id":"001i000001XR9dqAAD_0",
"type":"partnerLocation",
"contentType":"child"
},
{
"locationType":"Primary Location",
"addressLine1":"117 S 6th Ave.,",
"city":"Frisco",
"state":"Colorado",
"zipCode":"80443",
"country":"United States",
"phone":"+1.970.262.3515",
"latlon":"39.5754576,-106.0952117",
"distance":16.8,
"countryCode":"US",
"HSA":[
],
"id":"001i000001XR9dqAAD_1",
"type":"partnerLocation",
"contentType":"child"
},
{
"locationType":"Address",
"addressLine1":"RESORTINTERNET\r2718:FRISCO:80443\r117 S 6TH AVERM UNIT 2",
"city":"Frisco",
"state":"Colorado",
"stateCode":"CO",
"zipCode":"80443",
"country":"United States",
"latlon":"39.5744309,-106.0975203",
"distance":16.9,
"countryCode":"US",
"HSA":[
],
"id":"001i000001XR9dqAAD_100",
"type":"partnerLocation",
"contentType":"child"
}
],
"verticalHierarchyWraps":[
],
"primaryLocation":{
"locationType":"Headquarters",
"addressLine1":"117 S 6th Ave.,",
"addressLine2":"PO Box 2718",
"city":"Frisco",
"state":"Colorado",
"zipCode":"80443",
"country":"United States",
"phone":"(970) 262-3515",
"fax":"(970) 668-9431",
"latlon":"39.5754576,-106.0952117",
"distance":16.8,
"countryCode":"US"
}
}
];
for (var index in data)
{
var item=data[index];
console.log(item["name"]);
console.log(item);
}
</script>

Trying to alter JSON so it displays over multiple rows instead of single line using JSON_PRETTY_PRINT, not working

Here are my results:
[{"android_id":"4b76f380a2734530","date":"11\/11\/1992","entry":"Ate a peanut"},{"android_id":"4b76f380a2734530","date":"11\/11\/1994","entry":"Ate an banana"}]
What I want it to look like:
[
{
"android_id": "4b76f380a2734530",
"date": "11\/11\/1992",
"entry": "Ate a peanut"
},
{
"android_id": "4b76f380a2734530",
"date": "11\/11\/1994",
"entry": "Ate an banana"
}
]
I'm trying to use the JSON_PRETTY_PRINT function but it doesn't like it even thought I'm using PHP 5.6:
My code:
// Pring data as json string.
$json = json_encode($diary_entrys);
$json_string = json_encode($json, JSON_PRETTY_PRINT);
print_r($json);
Never mind, I should have used decode instead of encode, works fine now.