You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by Real Wes Williams <Th...@outlook.com> on 2015/08/31 20:43:29 UTC

Using JSON to create Regions Dynamically


I’m creating regions dynamically using JSON… at least that’s the goal. The JSONFormatter blows up when trying to convert the JSON fragment below to a PDXInstance in preparation to be read by Region Attributes. I am referring to the AbstractBaseController>convert(String son) method.  Does the json fragment need to be in an idiosyncratic format before being converted to PDX?

INFO: com.gemstone.gemfire.pdx.JSONFormatterException: Could not parse JSON document 

  protected PdxInstance convert(final String json){
    try{
      return (StringUtils.hasText(json) ? JSONFormatter.fromJSON(json) : null);
    }catch(JSONFormatterException jpe){
      throw new MalformedJsonException("Json doc specified is either not supported or invalid!", jpe);
    }
  }


{
  server: {
    dataPolicy: "PERSISTENT_PARTITION",
    partitionAttributes: {
      redundantCopies: 1
    },
    diskStoreName: "gemfire-store",
    indexUpdateType: "synchronous",
    //diskSynchronous: true,
    statisticsEnabled: true,
    "evictionAttributes": {
      "lruHeapPercentage": {
        "action": "overflow-to-disk"
      }
    }
  },
  client: {
    type: "PROXY",
    poolName: "publisher"
  }
}

Re: Using JSON to create Regions Dynamically

Posted by Wes Williams <ww...@pivotal.io>.
Thanks.  I'm generating regions dynamically now like a madman.

*Wes Williams | Pivotal Sr. **Data Engineer*
781.606.0325
http://pivotal.io/big-data/pivotal-gemfire

On Mon, Aug 31, 2015 at 4:04 PM, Jacob Barrett <jb...@pivotal.io> wrote:

> You have to quote all your property names and remove the // comments.
>
>
>
> Jacob Barrett
> Manager
> GemFire Advanced Customer Engineering (ACE)
> Pivotal
>
> jbarrett@pivotal.io
> 503-533-3763
>
> For immediate support please contact Pivotal Support at
> http://support.pivotal.io/
>
> On Mon, Aug 31, 2015 at 11:57 AM, Anthony Baker <ab...@pivotal.io> wrote:
>
> > Wes,
> > That doesn’t look like valid json to me…try http://jsonlint.com.
> > Anthony
> >> On Aug 31, 2015, at 11:43 AM, Real Wes Williams <Th...@outlook.com>
> wrote:
> >>
> >>
> >>
> >> I’m creating regions dynamically using JSON… at least that’s the goal.
> The JSONFormatter blows up when trying to convert the JSON fragment below
> to a PDXInstance in preparation to be read by Region Attributes. I am
> referring to the AbstractBaseController>convert(String son) method.  Does
> the json fragment need to be in an idiosyncratic format before being
> converted to PDX?
> >>
> >> INFO: com.gemstone.gemfire.pdx.JSONFormatterException: Could not parse
> JSON document
> >>
> >>  protected PdxInstance convert(final String json){
> >>    try{
> >>      return (StringUtils.hasText(json) ? JSONFormatter.fromJSON(json) :
> null);
> >>    }catch(JSONFormatterException jpe){
> >>      throw new MalformedJsonException("Json doc specified is either not
> supported or invalid!", jpe);
> >>    }
> >>  }
> >>
> >>
> >> {
> >>  server: {
> >>    dataPolicy: "PERSISTENT_PARTITION",
> >>    partitionAttributes: {
> >>      redundantCopies: 1
> >>    },
> >>    diskStoreName: "gemfire-store",
> >>    indexUpdateType: "synchronous",
> >>    //diskSynchronous: true,
> >>    statisticsEnabled: true,
> >>    "evictionAttributes": {
> >>      "lruHeapPercentage": {
> >>        "action": "overflow-to-disk"
> >>      }
> >>    }
> >>  },
> >>  client: {
> >>    type: "PROXY",
> >>    poolName: "publisher"
> >>  }
> >> }
>

Re: Using JSON to create Regions Dynamically

Posted by Jacob Barrett <jb...@pivotal.io>.
You have to quote all your property names and remove the // comments.



Jacob Barrett 
Manager 
GemFire Advanced Customer Engineering (ACE) 
Pivotal

jbarrett@pivotal.io 
503-533-3763

For immediate support please contact Pivotal Support at http://support.pivotal.io/

On Mon, Aug 31, 2015 at 11:57 AM, Anthony Baker <ab...@pivotal.io> wrote:

> Wes,
> That doesn’t look like valid json to me…try http://jsonlint.com.
> Anthony
>> On Aug 31, 2015, at 11:43 AM, Real Wes Williams <Th...@outlook.com> wrote:
>> 
>> 
>> 
>> I’m creating regions dynamically using JSON… at least that’s the goal. The JSONFormatter blows up when trying to convert the JSON fragment below to a PDXInstance in preparation to be read by Region Attributes. I am referring to the AbstractBaseController>convert(String son) method.  Does the json fragment need to be in an idiosyncratic format before being converted to PDX?
>> 
>> INFO: com.gemstone.gemfire.pdx.JSONFormatterException: Could not parse JSON document 
>> 
>>  protected PdxInstance convert(final String json){
>>    try{
>>      return (StringUtils.hasText(json) ? JSONFormatter.fromJSON(json) : null);
>>    }catch(JSONFormatterException jpe){
>>      throw new MalformedJsonException("Json doc specified is either not supported or invalid!", jpe);
>>    }
>>  }
>> 
>> 
>> {
>>  server: {
>>    dataPolicy: "PERSISTENT_PARTITION",
>>    partitionAttributes: {
>>      redundantCopies: 1
>>    },
>>    diskStoreName: "gemfire-store",
>>    indexUpdateType: "synchronous",
>>    //diskSynchronous: true,
>>    statisticsEnabled: true,
>>    "evictionAttributes": {
>>      "lruHeapPercentage": {
>>        "action": "overflow-to-disk"
>>      }
>>    }
>>  },
>>  client: {
>>    type: "PROXY",
>>    poolName: "publisher"
>>  }
>> }

Re: Using JSON to create Regions Dynamically

Posted by Anthony Baker <ab...@pivotal.io>.
Wes,

That doesn’t look like valid json to me…try http://jsonlint.com.

Anthony

> On Aug 31, 2015, at 11:43 AM, Real Wes Williams <Th...@outlook.com> wrote:
> 
> 
> 
> I’m creating regions dynamically using JSON… at least that’s the goal. The JSONFormatter blows up when trying to convert the JSON fragment below to a PDXInstance in preparation to be read by Region Attributes. I am referring to the AbstractBaseController>convert(String son) method.  Does the json fragment need to be in an idiosyncratic format before being converted to PDX?
> 
> INFO: com.gemstone.gemfire.pdx.JSONFormatterException: Could not parse JSON document 
> 
>  protected PdxInstance convert(final String json){
>    try{
>      return (StringUtils.hasText(json) ? JSONFormatter.fromJSON(json) : null);
>    }catch(JSONFormatterException jpe){
>      throw new MalformedJsonException("Json doc specified is either not supported or invalid!", jpe);
>    }
>  }
> 
> 
> {
>  server: {
>    dataPolicy: "PERSISTENT_PARTITION",
>    partitionAttributes: {
>      redundantCopies: 1
>    },
>    diskStoreName: "gemfire-store",
>    indexUpdateType: "synchronous",
>    //diskSynchronous: true,
>    statisticsEnabled: true,
>    "evictionAttributes": {
>      "lruHeapPercentage": {
>        "action": "overflow-to-disk"
>      }
>    }
>  },
>  client: {
>    type: "PROXY",
>    poolName: "publisher"
>  }
> }