JSON.load giving input.json.mapping.error

Hello all,

Running into a JSON.load issue using json (1.8.1 java, 1.8.0 java, 1.7.7
java, 1.7.6 java) gem

So here is the scenario we store some prop values for products we have
as json string in mysql db. This was all working fine until we started
adding more products and more attributes to these products. For some of
these products when I attempt to load via JSON.load() I have seen this
error injected randomly which is causing ruby to blow up and not return
my json object.

JSON::ParserError dump:
“accountOnFile”:{“pseudoDDAEnabled”:false,“uniquenessCalculationMethod”:null,“lowBalanceThreshold”:[],“identificationRequiredForUserType”:[],“emailRequired”:false,"EMAILREQUIREDFORUSERTYPE{“errorCode”:“input.json.mapping.error”,“message”:“Bad
Request: Unable to map the request JSON to an entity. Invalid limits”}’

actual json value in db:
“accountOnFile”:{“DAEnabled”:false,“uniquenessCalculationMethod”:null,“emailRequired”:false,“identificationRequiredForUserType”:[],“lowBalanceThreshold”:[],“primaryUserType”:“DEFAULT”,“defaultAccountCode”:“account”,“EMAILREQUIREDFORUSERTYPE”:[],“defaultTimeZone”:null,“dateOfBirthRequired”:false,“numberOfRequiredPhones”:0,“defaultCurrency”:“USD”,“externalRefRequiredForUserType”:[],“idvRequiredForUserType”:[],“upgradeTags”:[],“languageRequired”:false,“requiredIdentificationForUserType”:[],“uniquenessLimits”:[],“maximumUsersOfType”:[],“numberOfIdentification”:0,“OnAccountCreation”:false,“channelRequiredForUserType”:[],“genderRequired”:false,“period”:63,“historyFormat”:null,“allow”:false,“channelRequired”:false,“exclude”:false,“requiredIdentification”:[],“externalRefRequired”:false,“numberOfPhones”:0,“numberOfRequiredIdentification”:0,“accountCode”:“balanceadjustment”,“phoneRequiredForUserType”:[“phoneRequired=true”],“defaultUserType”:“DEFAULT”,“allow”:true,“dateOfBirthRequiredForUserType”:[],“ALength”:13,“UserType”:[],“DAPrefix”:null,“strategy”:“Xzz”,“upgradeAllowed”:false,“defaultStrategy”:“gift”,“demographicRestrictionsCode”:“US”,“numberOfRequiredIdentificationForUserType”:[],“uniquenessCheckRequired”:false,“userSettings”:null},“bpayment”:{“monthlyCountLimit”:0,“monthlyAmountLimit”:0,“dailyCountLimit”:0,“maximumPayeesAllowed”:0,“billPaymentProvider”:null,“weeklyAmountLimit”:0,“billPaymentSupported”:false,“dailyAmountLimit”:0,“weeklyCountLimit”:0}

I’ve tried adding :max_nesting => false and it has had no effect. Any
help is appreciated as Im running out of ideas

Michael David wrote in post #1155753:

Hello all,

Running into a JSON.load issue using json (1.8.1 java, 1.8.0 java, 1.7.7
java, 1.7.6 java) gem

So here is the scenario:

Can you post a program that is 10-15 lines long that produces the error
you are seeing. It is hard to debug invisible code. My only shot in the
dark at this point is: your json below is invalid, which anyone with
even a cursory knowledge of json would spot immediately, and JSONlint
would point out to anyone else.

JSON::ParserError

actual json value in db:

“accountOnFile”:{“DAEnabled”:false,“uniquenessCalculationMethod”:null…}

I’ve tried adding :max_nesting => false and it has had no effect. Any
help is appreciated as Im running out of ideas

You didn’t get a JSON::NestingError, which if you check the ruby JSON
docs is an error defined by the json module. In any case, a cursory
glance at your json string reveals you only have one nested object.
Furthermore, the docs say the default for max_nesting for
load() is false.

What happens when you try load() on the following string in your
program:

‘“hello”:{“planet”:“world”}’

Figured this one out. It turns out it was an error in the java used to
create this json object. Prevalidation was failing and it was injecting
the error msg into the json which was invalid. Sorry for wasting time,
and thanks to all those that tried to help.