Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Making a custom field , which computes its value in value code and returns a json array.
In value code, sql query returns a result which is json encoded !
it works properly , result is returned correctly in the preview but not when the end-point is called !
Expected Result:-
[
{
"Nid": "32",
"PHP": "[{"dish1_like":"0","dish2_like":"0","dish3_like":"3","dish4_like":"0","dish5_like":"3","dish1_dislike":"4","dish2_dislike":"4","dish3_dislike":"0","dish4_dislike":"2","dish5_dislike":"1"}]"
}]
Result returned :-
[
{
"Nid": "32",
"PHP": "[{"dish1_like":"0","dish2_like":"0","dish3_like":"3","dish4_like":"0","dish5_like":"3","dish1_dislike":"4","dish2_dislike":"4","dish3_dislike":"0","dish4_dislike":"2","dish5_dislike":"1"}]"
}]
the php property is returned by value code !
it reutrns "e; instead of actual " .
Comments
Comment #2
kylebrowning CreditAttribution: kylebrowning commentedThis is a custom field that has JSON in it? Im sorry but we can't really support that from Services.
You need to alter the response from services to handle your custom case.
Look at services.api.php for ways to do so.