Zend Framework

Silence cycle exception in Zend_Json_Encoder

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6.0RC2
  • Fix Version/s: 1.6.0
  • Component/s: Zend_Json
  • Labels:
    None

Description

I need a way to silence the exception thrown when cycle detection is switched on and one is detected in Zend_Json_Encoder.

This relates to issue ZF-4040.

The aim is to still generate a valid JSON string even if cycles are detected. In place of the repeated object we could insert

"* RECURSION ([Class Name]) *"

into the JSON string.

To accomplish this we could use:

protected function __construct($cycleCheck = false, $silenceCycleCheck = false)

or convert $_cycleCheck to an integer and introduce a Zend_Json_Encoder::SILENT_CYCLE_CHECK constant to avoid a new constructor/method argument.

Zend_Json_Encoder::encode($value, Zend_Json_Encoder::SILENT_CYCLE_CHECK);

Activity

Hide
Christoph Dorn added a comment -

Based on IRC discussion with Matthew we have decided to add an $options argument that accepts an associative array.

The option to silence the exception will be called "silenceCyclicalExceptions".

Show
Christoph Dorn added a comment - Based on IRC discussion with Matthew we have decided to add an $options argument that accepts an associative array. The option to silence the exception will be called "silenceCyclicalExceptions".
Hide
Wil Sinclair added a comment -

Updating for the 1.6.0 release.

Show
Wil Sinclair added a comment - Updating for the 1.6.0 release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: