skip to Main Content

I run identical code (my Dancer2 app) locally on my mac’s plenv’s v5.26.2 but when I run the app (whether with plackup or starman or proxied behind Apache, with our without SSL, or requesting locally on each location with Curl) the server-running instance is stringifying everything in the responding payloads.

"custid": "5000", on the ubuntu 16 server (system perl v5.22.1 – libraries are same versions as my local instance)

"custid": 5000, on my local machine.

In my config.yml I got (among other things, but this is the only engines block)

content_type: "application/json"
serializer: "JSON"

engines:
  serializer:
    JSON:
      pretty: 1

The data itself does come from a DB but my local machine and the server’s DBIx::Class respectively connect to the same remote (not local to the ubuntu) mysql server with the same ResultSources..

One thing I can think of is the server to be using Cpanel::JSON::XS and something is “touching” the results as strings before they get to the serializer, but I’m not sure how to check which JSON library is actually used on each running app instance.

So –
How come I get different stringification with the same code?
How to check what JSON library is used on each instance?

2

Answers


  1. Chosen as BEST ANSWER

    Yes it seems it was the DBD::mysql that was installed. I had 4.033 (and I had no mysql_config so probably that kept it back) and there seems there are a few changes since that might be the cause but not sure:

    Perhaps one of:

    Numeric conversions in perl which led to overflow/underflow was ignored even when mysql strict mode was enabled

    Use correct format in printf instead of casting variable types

    Or any of the changes around having mysql_config available. Either way big ups to the maintainers! Also this server was upgraded from 14.04 LTS which of course changed system perl things. (But I don't recall noticing the stringification on 14.04)


  2. Dancer2 uses JSON::MaybeXS to decide which module to load. You can use the ->JSON class method on that to ask it which one it loaded.

    $ perl -MJSON::MaybeXS -E 'say JSON::MaybeXS->JSON'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search