ResourceFromDocument doesn't work when types in Json are not plural
Hi, I'm using JsonApiNet to deserialize a compound Json document, however the data types in the Json are singular rather than plural (e.g. "vendor" rather than "vendors"). This causes an error when calling JsonApi.ResourceFromDocument. Am I missing something? If I change the data types to plurals (i.e. vendors, addresses and contacts) it works fine. I do not have control over the generation of the Json.
I have attached the Json that does not work.
Many thanks,
Phil
I have found the issue in ReflectingTypeResolver.cs. Changing: private static string Classify(string typeName) { return typeName.Underscore().Singularize().Pascalize(); } to: private static string Classify(string typeName) { return typeName.Underscore().Singularize(false).Pascalize(); } The bool parameter "inputIsKnownToBePlural" defaults to true, which causes an error if it's not plural.
Nice find. Want to submit a PR?
On May 13, 2016, at 05:57, phil-E [email protected] wrote:
I have found the issue in ReflectingTypeResolver.cs. Changing: private static string Classify(string typeName) { return typeName.Underscore().Singularize().Pascalize(); } to: private static string Classify(string typeName) { return typeName.Underscore().Singularize(false).Pascalize(); } The bool parameter "inputIsKnownToBePlural" defaults to true, which causes an error if it's not plural.
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub
Has this been fixed yet?
It hasn't. I'll gladly accept a pull request otherwise I'll see if I can squeeze some time in for this this week
Edit: Typos, thanks Siri.
On Sep 18, 2016, at 16:26, lordplagus02 [email protected] wrote:
Has this been fixed yet?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.