Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:21:33+00:00 2026-06-10T18:21:33+00:00

TL/DR: What’s a good way to use an underscored naming convention serverside (RoR) with

  • 0

TL/DR: What’s a good way to use an underscored naming convention serverside (RoR) with a camelCased naming convention clientside (JS)

Server-side programming environments like Ruby on Rails use underscored variables. Conventionally, JavaScript uses camelCased variables. This is problematic when sending data from the client to the server.

For example, consider sending user information to the client. There may be a property in the database called num_times_ordered, yet in JavaScript you’d traditionally want to refer to this as numTimesOrdered.

Has anyone come up with an elegant way of dealing with this? Here are some options, none particularly nice:

  1. Convert data to camelCase when fetched from server.
  2. Use camelCase when sending it from the server
  3. Use an underscored naming convention in your Javascript (although then you’re inconsistent with any third party libraries, like jQuery)
  4. Use a camelCased naming convention on your backend (although then you’re inconsistent with your backend’s conventions)

I’m leaning towards #3, and using underscores in my JavaScript. It’ll look weird when I use camelCased third party libraries, though.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:21:35+00:00Added an answer on June 10, 2026 at 6:21 pm

    I believe ember.js (via Ember Data) takes approach #1: converting underscored JSON to camelCase on the client-side when fetched; and doing the reverse before posting back to the server.

    I’ve been working on a small library that performs these conversions: https://github.com/domchristie/humps, allowing you to do things like:

    // GET
    $.ajax({
      url: '/posts',
      dataType: 'json',
      success: function(data, status, xhr) {
        data = humps.camelizeKeys(data);
      }
    });
    
    // POST
    $.ajax({
      type: 'POST',
      url: '/posts'
      dataType: 'json',
      data: humps.decamelizeKeys({
        title: "Foo",
        publishedAt: "2012-09-03T21:35:46.068Z"
      })
    });
    // Sends: { title: "Foo", published_at: "2012-09-03T21:35:46.068Z" }
    

    I should add, it has not been heavily tested, but contributions welcome!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am confused How to use looping for Json response Array in another Array.
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.