Configurable camelizing type values
See original GitHub issueAs was discovered in PR https://github.com/yury-dymov/json-api-normalizer/pull/33 there is potential issue with camelizing type’s values inside relationships data objects.
Despite camelizing option explicitly called: camelizeKeys: true
it’s affecting type values too.
It will be great to have separate configurable option to camelize type values.
Input:
const json = {
data: [
{
type: 'post',
relationships: {
'rel1-to-camelize': {
data: [
{
id: 4,
type: 'type1-to-camelize',
},
],
},
},
id: 2620,
},
],
};
Output:
const output = {
post: {
2620: {
type: 'post',
id: 2620,
relationships: {
rel1ToCamelize: {
data: [
{
id: 4,
type: 'type1ToCamelize',
},
],
},
},
},
},
};
In my point of view this should work by this way:
result = normalize(json, {
camelizeKeys: true,
camelizeTypeValues: true,
});
And camelizeTypeValues
should be in false
state by default.
This is breaking change
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
camelize - MuleSoft Documentation
camelize (text: String): String. Returns a string in camel case based on underscores in the string. All underscores are deleted, including any underscores...
Read more >Phoenix.Naming — Phoenix v1.6.15 - HexDocs
Functions ; camelize(value). Converts a string to camel case. ; camelize(value, atom) ; humanize(atom). Converts an attribute/form field into its humanize version.
Read more >Don't camelize field names by default · Issue #1707 - GitHub
When migrating from v1.7 syntax to v1.8 class syntax I discovered that the name attribute on an instance of Field was being camelized....
Read more >String - Rails API
By default, camelize converts strings to UpperCamelCase. If the argument to camelize is set to :lower then camelize produces lowerCamelCase.
Read more >Rails - Serialize Model to JSON with camelize - Stack Overflow
Put it in values = hash.map do |key, value| Minor change, just thought I'd mention it. – joshfindit. Jun 1, 2016 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for the help 😃
I agree that consistency is important. And additionally there could be case when you need to compare type value with the resources stored in your local repository by their type key. And since they are both camelized by default this will be easier then.