0

Hey I am stuck in the middle of my code. I am getting some input data from my partner and I get an array. At the 0 index of the array there are 3 strings. The array looks like this

array
0 => 
   object(MunichInnovationGroup\PatentBundle\Entity\PatentIdJson)[1405]
   private 'patentId' => string 'EP.02708872.A' (length=13)
   private 'jsonData' => string '{"ops:world-patent-data": {
    "@xmlns":   {
    "ops": "http://ops.epo.org",
    "$": "http://www.epo.org/exchange",
    "ccd": "http://www.epo.org/ccd",
    "xlink": "http://www.w3.org/1999/xlink"
  },
  "ops:meta":   {
  "@name": "elapsed-time",
  "@value": "69"
  }
  private 'status' => string 'Found' (length=5)

What I am interested in is the 'jsonData' String. Can I covert this whole array to a multidimensional array or just get the 'jsonData' and convert it into an array so that I get the information what I need from the 'jsonData'.

Thanks

2
  • Does the MunichInnovationGroup\PatentBundle\Entity\PatentIdJson class have a method to return jsonData? Commented Sep 27, 2012 at 18:19
  • yes getjsonData() in the Entity class Commented Sep 27, 2012 at 18:24

2 Answers 2

1

what you need is json_decode and you can do the following:

$jsonObject = json_decode($myArray[0]->getjsonData(), true);

That will generate an object from the jsonData your partner is providing in the array

Sign up to request clarification or add additional context in comments.

1 Comment

but to get the assocciated array we need to pass true as 2nd parameter to json_decode
1

Based on your comment, you can get to the data using:

$jsonData = $your_array[0]->getjsonData();

Assuming that the MunichInnovationGroup\PatentBundle\Entity\PatentIdJson extends the MunichInnovationGroup\PatentBundle\Entity class.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.