Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Hello i need help in parsing an object that is being return to java. I am running some automated tests using selenium. In my test i am using the framework to call javascript functions and what i am doing is assigning what is passed back from the javascript function to a java object. The event object passed from javascript looks like this

{
  data={
    isFailover=false,
    baseClip={
        expression=full,
        isAd=true,
        connectionBitrate=0,
        baseURL=null,
        contentCustomData={
            fw: titleId=null,
            fw: advertiserId=null,
            fw: category=null
          },
          overlays=[],
          ratings=[]
        }
    }
}

I have an object called "responseToMediaIsAd" defined as

private static Object responseToMediaIsAd;

The data response is being outputted (above) comes when i do this

System.out.println(responseToMediaIsAd);

So its great that i get data back:-) The only problem now is HOW do i parse thru this data. do i have to convert it to json then parse that data?... Can someone tell me how to read the value of (say isFailover, and isAd), ie need to know how to step through and get values

I need to know how to use Java to get to this data that Javascript is returning. Thank you

share|improve this question

1 Answer 1

Well, you can use the Jackson JSON parser library, or if you know regex, you can painfully roll a custom one with some crafted queries.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.