Link to home
Start Free TrialLog in
Avatar of Ingo Foerster
Ingo Foerster

asked on

PHP JSON Encode for Java-Script?

Hello,
Is it possible to encode a JSON in PHP in Java-Script Style?
As sample,

[
	{ id:6, status:"new", text:"Task 6", tags:"webix,kanban", comments:[{text:"Comment 1"}, {text:"Comment 2"}], personId: 2 },
];

Open in new window


A similar export I did is:

[
	{ "id":"6", "status":"new", "text":"Task 6", "tags":"webix,kanban", "comments":"[{"text":"Comment 1"}, {"text":"Comment 2"}]", "personId": "2" },
];

Open in new window


Special the part:
comments:[{text:"Comment 1"}, {text:"Comment 2"}]

Open in new window

looks like a JSON encoded string inside a JSON?
How is this possible to generate with an SQL query?
SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the two questions are :
looks like a JSON encoded string inside a JSON?
How is this possible to generate with an SQL query?

none of you comments give the author an answer talking about.
The question is phrased badly - not really clear what the author wanted - the answers don't match because the question is not clear.

Therefore recommend delete.
someone wanting to send valid json from PHP would benefit from what I've suggested. Olaf goes on to explain why. i believe those comments are useful and should be retained
It's annoying, if not worse, that questions are requested to be closed with recommendations even before the OP has come back once. Why not be a little more patient? This mainly goes to EE moderation.

Bye, Olaf.