Error occurs when field value has characters that can be converted to floating point

Created on 10 October 2021, about 3 years ago
Updated 28 April 2023, over 1 year ago

Problem/Motivation

If field value has a value formatted with ???E??? (Ex: 100E200), json_decode() function will return float point number value. And then Views will return error with "json_encode error: Inf and NaN cannot be JSON encoded". The value in this format mean floating point in JSON.

Steps to reproduce

1. Add the Text (plain) field to one of the content types. In this case field_test.
2. On the node creation screen, enter a value of 100E200 for field_test and save it.
3. Create a view of Rest Export Nested. Modify the condition so that the content from the previous step is displayed and add field_text to the Fields section.
4. Save the view and access the API path.

Proposed resolution

I think this code expects to return an object or array, so checking the type with the if syntax solves the problem.

Remaining tasks

Nothing

User interface changes

Nothing

API changes

Nothing?

Data model changes

Nothing

🐛 Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

🇯🇵Japan u7aro Japan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇵🇹Portugal nsalves

    Hey u7aro, I checked your steps and although I'm able to get the results you have in your screenshot I don't seem to find the error in views that you described. Does this still happen? When does the error occur?
    Thanks in advance

  • Status changed to Postponed: needs info over 1 year ago
Production build 0.71.5 2024