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 6133021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:10:25+00:00 2026-05-23T17:10:25+00:00

This is a pretty straightforward question and I’m trying to bridge the gaps in

  • 0

This is a pretty straightforward question and I’m trying to bridge the gaps in my knowledge.

Quite simply the applications work as follows:
1: i: web app creates a hash of values
1: ii: Turns this hash into JSON
1: iii: Sends the JSON across to another application via POST
THIS IS THE MAIN QUESTION

2: i: other web app receives the JSON, deserializes and turns back into an object.

@hostURL = 'http://127.0.0.1:20000/sendJson'

For 1 I’ve got i and ii done. Not too difficult.

@myHash = HASH.new
    @myHash =
    {
      "myString" => 'testestestes'
      "myInteger" => 20
    }

    @myJsonHash = @myHas.to_json

Sending a post request in my application looks like this:

  res = Net::HTTP.post_form(URI.parse(@hostURL),
    {'myString'=>'testestestest, 'myInteger' => 20})

However I’m at a loss as to how to send the JSON hash across through post.

As for 2:

  @request = UserRequest.new({:myString => params[:myString], :myInteger => params[:myInteger] })
           if @request.save
    #ok
      puts "OBJECT CREATED AND SAVED"
    else
    #error
      puts "SOMETHING WENT WRONG WITH OBJECT CREATION"

Would this suffice as I hear Rails automatically deserializes on receiving a request.


On a side note: What should the response be?

These are 2 web apps communicating so returning some html would be bad. Possibly a numeric response? 200? 404?

Are there any industry standards when it comes to responding with data rather than responding to a browser

  • 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-05-23T17:10:26+00:00Added an answer on May 23, 2026 at 5:10 pm

    You want to use from_json which does the opposite of to_json. This will take the object being sent in JSON and convert it into ruby so your model or however you save it will understand.

    @post = Post.new
    @post.name = "Hello"
    
    #this converts the object to JSON
    @post.to_json 
    
    @post = You want to use `from_json` which does the opposite of `to_json`. This will take the object being sent in JSON and convert it into ruby so your model or however you save it will understand.
    
    
    @post = Post.new
    @post.name = "Hello"
    
    #this converts the object to JSON
    @post.to_json 
    
    @post = {
         "name" => 'Hello'
       }   
    
    #this puts it back into JSON
    @post.from_json
    
    @post.name = "Hello"
    @post.to_json
    

    In terms of sending JSON (server side) to a controller that is usually done from JavaScript or AS3.

    You should explain how you are posting. From a form, from a link. That matters; however, the easiest way is to use jQuery.

    $.ajax({
        type: 'POST',
        url: url,
        data: data,
        success: success,
        dataType: json
    });
    

    Here you want the url to be the post url such has app.com/posts (your domain, and then a controller) and then the data should be in JSON format, for example:

    data = {
             "name" => 'Hello'
           }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a pretty straightforward question, but I'm trying to understand some of
This is a pretty straightforward architectural question, however it's been niggling at me for
Pretty straightforward question: On web apps they force the title of the popup to
pretty straightforward question: Is there a good web services solution for Joomla1.5+? I've been
This should be a pretty straightforward classes and interfaces question, but please bear with
This is a pretty straightforward question, so I don't think I need to post
This seems like a pretty straightforward question but I haven't been able to find
I'm pretty sure this is a rather simple and straightforward question for anyone that
Well, first of all sorry about this question it must be pretty straight forward
This should be pretty straightforward I would think. I have this string: [quote=Joe Johnson|1]Hi![/quote]

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.