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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:54:39+00:00 2026-06-08T10:54:39+00:00

Using SQL, how can I select the value for conversion_event from the JSON below?

  • 0

Using SQL, how can I select the value for “conversion_event” from the JSON below?

{"str":[1,1342886173,100000627571405,"offsite_conversion.lead",{"action.type":"offsite_conversion","conversion_event":387756207950188,"tag":"lead"},["conversion_event"],[],{"amount":12623486},"1:11:1:0:0:1:0"]}  

There are some unusual things in here, for example JSON within JSON, and the square brackets. Assume that lengths of all values vary by row, so you cannot slice by a set number of character positions.

  • 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-08T10:54:43+00:00Added an answer on June 8, 2026 at 10:54 am

    Based on comments:

    declare @astr varchar(max);
    declare @start int;
    declare @end int;
    set @astr = '{"str":[1,1342886173,100000627571405,"offsite_conversion.lead",{"action.type":"offsite_conversion","conversion_event":387756207950188,"tag":"lead"},["conversion_event"],[],{"amount":12623486},"1:11:1:0:0:1:0"]}';
    
    select @start =  charindex('"conversion_event":',@astr)
    select @end = charindex(',"tag":',@astr)
    
    select substring(@astr,@start,@end-@start);
    

    returns

    "conversion_event":387756207950188
    

    add

    set @start = @start + 19;
    

    to get just the number.


    SELECT substring('{"str":[1,1342886173,100000627571405,"offsite_conversion.lead",{"action.type":"offsite_conversion","conversion_event":387756207950188,"tag":"lead"},["conversion_event"],[],{"amount":12623486},"1:11:1:0:0:1:0"]}',
                      101,16);
    

    or

    select substring('{"str":[1,1342886173,100000627571405,"offsite_conversion.lead",{"action.type":"offsite_conversion","conversion_event":387756207950188,"tag":"lead"},["conversion_event"],[],{"amount":12623486},"1:11:1:0:0:1:0"]}',
                     151,16)
    

    Ok this is the structure of the object:

    {
      "str":[1,
             1173,
             10005,
             "offsite_conversion.lead",
             {"action.type":"offsite_conversion",
              "conversion_event":387756207950188,
              "tag":"lead"},
            ["conversion_event"],
            [],
            {"amount":14486},
            "1:11:1:0:0:1:0"
    ]}
    

    An object with an atribute str which is an array.

    The 5th element has a 2nd attribute conversion event

    The 6th element is an array of one element which is conversion event.

    So the question is… is this structure the same and which of these do you want?

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

Sidebar

Related Questions

For example using SQL I can do: SELECT (a+b) as c FROM table WHERE
I was wondering how you can recover data from your logfile. I'm using sql
I'm using SQL Server 2005. With the query below (simplified from my real query):
i am using sql server 2000 can i use full text search on the
Using SQL Server 2005, how can I authenticate a username/password pair against a non-AD
I can drop a SqlServer Backup Device using SQL-DMO using the following pseudo-code: SQLDMO.SQLServer2
Can we find all tables in the msaccess using sql . as we do
How can I update an entity effectively in hibernate just as by using SQL.
Using t-sql, how can i find if all SQL Logins have strong passwords on
I am wondering if you can use Linq to SQL using a .mdf file

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.