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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:15:48+00:00 2026-05-27T18:15:48+00:00

I need to grab the values of a JSON string stored within a function

  • 0

I need to grab the values of a JSON string stored within a function in a script tag like this:

<script type="text/javascript">
    my.function("bar", {"foo1": false, "foo2": true, "foo3": "foobar!"});
</script>

I can get to the particular tag using Mechanize like so:

parser.xpath("//script[ contains(text(), 'my.function')]").text

but I’m not sure how to go on from there. How can I extract the JSON part of the string and convert it into a hash so that I can extract the values?

  • 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-27T18:15:49+00:00Added an answer on May 27, 2026 at 6:15 pm

    If the form doesn’t change, you can do

    JSON.parse(/\{.*\}/.match(txt)[0])
    

    with json gem. Be aware that there are several points of failure – either check each step, or place a nice rescue somewhere.

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

Sidebar

Related Questions

I need to grab the base64-encoded representation of the ViewState . Obviously, this would
I need to grab values from the querystring and inject them into a getURL();
I've got a string of HTML that I need to grab the [Title| http://www.test.com]
Alright cannot find this anywhere and I was wondering how to grab the values
I need LINQ to grab a whole table, but this seems not to be
This is the code to grab tweets, but i need this in PHP, can
I need some simple help with regex I want to grab the values in
I need to grab all records from a database table where the values in
I need to write a regular expression to grab just the values from the
Per the following multiselect I need to grab the selected values that are selected

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.