Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use browser API or Ruby stdlib?#116

Answeredbyrubys
yerlaser asked this question inQ&A
Discussion options

Hi,
I am doing some basic tests of the tech and so far liking it.
Sometimes it seems to be too good to be true.

I have a question.
If am to fetch json from a backend server, should I use browser api (i.e. fetch) or ruby's own methods?
In the former case, what would I get? Can I somehow convert it to Ruby hash or should I pretend that Ruby (thanks to transpiling) gains JS json support?

You must be logged in to vote
Answered by rubysMay 15, 2021

I use the browser API, and pretend that the JSON returned is anOpenStruct. Each of the following transpire to the same thing:

json['field']json[:field]json.field

Replies: 1 comment 1 reply

Comment options

I use the browser API, and pretend that the JSON returned is anOpenStruct. Each of the following transpire to the same thing:

json['field']json[:field]json.field
You must be logged in to vote
1 reply
@yerlaser
Comment options

That's very cool. Thanks for the fast reply!

Answer selected byyerlaser
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@yerlaser@rubys

[8]ページ先頭

©2009-2025 Movatter.jp