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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:16:43+00:00 2026-05-28T15:16:43+00:00

I need to convert a string to a JSON object that gets returned from

  • 0

I need to convert a string to a JSON object that gets returned from a Learning Management System. Once the string is a JSON Object I’m going to use it as part of a jQuery plugin I am writing. Here is what I have so far:

callback to convert: (I do not have access to the server-side code (it resides on an LMS (AICC), I just access it via javascript and the callback is below, so I am stuck with this text. I do believe after each line there is \n, but this is the exact format I receive …. nothing but text.)

ERROR=0
ERROR_TEXT=Successful
VERSION=2.2
AICC_DATA=[CORE]
STUDENT_ID=01234567
STUDENT_NAME=Doe, John R
SCORE=83
TIME=02:35:37
CREDIT=C
LESSON_LOCATION=page_1               
LESSON_STATUS=INCOMPLETE
[Core_Lesson]
[Objectives_Status]

The is what I am looking to convert it to:

{'ERROR':'0','ERROR_TEXT':'Successful','VERSION':'2.2','AICC_DATA':'[CORE]','STUDENT_ID':'01234567','STUDENT_NAME':'Doe, John R','SCORE':'83','TIME':'02:35:37','CREDIT':'C','LESSON_LOCATION':'page_1','LESSON_STATUS':'INCOMPLETE'}

Here is the jQuery I am using: (as you can see I am trying to do this without a loop if possible 🙂

$.get(_url,{command:"GetParam",version:"2.2",session_id:_sid},function(response)
{
    /* this is my attempt at using a RegExp */
    var match = RegExp('[?&]' + urlVar + '=([^&]*)').exec(response); 
    /* I thought maybe I could do it using an eval(), but I get an error -> Expected "]" */
    var t = eval('{['+response+']}');                       
});

I am confident that I could figure this out using a loop, but I really would like to get this working without the for loop. Is this even possibible? Thanks!

  • 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-28T15:16:44+00:00Added an answer on May 28, 2026 at 3:16 pm

    If your lines do end in “\n” then you could try this:

    var obj = {};
    theTextYouGetFromTheServer.replace(/([^=]+)=(.*)\n/g, function(_, name, value) {
      obj[name] = value;
    });
    

    If your names can contain “=” of course that’d be a problem.

    What that does is match the basic format of your name/value lines (NAME=VALUE) and builds an object. The JavaScript .replace() method for strings calls that function repeatedly for each successive match, with the parameters being the entire match (which here we don’t care about), and then each matched group (things in parens in the regex).

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

Sidebar

Related Questions

I have an xml document object that I need to convert into a string.
I need to convert a string to a monetary format of {###}.###.###,## that is
Let's say I have an integer that I need to convert to a string
I need to convert from a SQLVARCHAR to a string data type Variable definitions
I have a string that I need to convert to the equivalent array of
I need to convert a HashMap<String, Object> to an array; could anyone show me
I need to somehow convert a single json string into multiple objects of a
I need to send a JSON string to a number of TCP clients from
I have data that I convert to JSON. I need storage to be very
I have a List<class> that I would like to convert into a json object

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.