Hi John,

Thanks for the example! My query is more related to schemaless entity.

*Actually this example refers to domain class "Customer" and converts pojo
to JSON. But that also means it has "schema" [Well defined domain model --
We know number of attributes and type of attributes in advance].*

I am looking for JSON but I don't have "schema" defined as "Customer". Why?
Because if I setup schema/domain class, then I have to frequently change my
domain class and database while onboarding new column or any upgrades to
existing column,

Thus above step will force me to clear & destroy existing region and
recreate it with new model class and pdx metadata.

*Let's say from "Source" itself I am receiving json as string and then I
want to store such json document as pdx serializable in region. *

Then I have 3 ways which I am replicating once again from my first email as
below! Any thoughts for that?

*Case1: Primary key <java.lang.String>*

region.put(String.valueOf(i), JSONFormatter.fromJSON(obj.toJSONString()));

For above, I believe it should be --> Region<String,PdxInstance> then how
does it look like in spring data geode xml configuration?


*Case2: Primary Key <? extends java.lang.Serializable>*

region.put (new CustomObject() , JSONFormatter.fromJSON(obj.
toJSONString()));

For above, I believe it should be --> Region<CustomObject,PdxInstance> then
how does it look like in spring data geode xml configuration?

*Case3: Is below case valid one and recommended ?*

@Region
Class JSONRegion {
     CustomPrimaryKeyObject primaryKey;
     JSONObject jsonObject; [org.simple.Json library or Jackson library]

     // Constructor + Getter/Setter
}

Thanks & Regards,




- Dharam Thacker

On Sun, Jan 1, 2017 at 4:53 AM, John Blum <[email protected]> wrote:

> Also note, here is an example...
>
> https://github.com/spring-projects/spring-gemfire-examples/tree/master/
> quickstart/json
>
> On Sat, Dec 31, 2016 at 3:22 PM, John Blum <[email protected]> wrote:
>
>> Dharam-
>>
>> You should take a look at this...
>>
>> http://docs.spring.io/spring-data-gemfire/docs/current/refer
>> ence/html/#bootstrap:region:json
>>
>> Also, be aware that if you stick a (JSON) "String" in a Region as a value
>> (i.e. Region.put(key, stringValue)) then the type of the value will be a
>> String, not a PDX instance as I assume you would expect.  Geode has no idea
>> whether you are sticking JSON into a Region or a String.
>>
>> Additionally, using JSONFormatter is clunky and limiting since you are
>> now tied to the JSON processing implementation of JSONFormatter.
>> Likewise, it only knows about JSON Strings (PdxInstance:fromJSON(:String))
>> and PDX Instances (toJSON(:PdxInstance)).  What happens if you pass in
>> an Object? What then?
>>
>> Under-the-hood, the SDG Region auto-proxy support uses JSONFormatter,
>> but also knows what to do with a POJO if a Region.put(key, Object)
>> occurs since that Region is proxied to store JSON, err... PDX content.
>>
>> You must have the JSON data stored in Geode as a PdxInstance to be able
>> to index and query the JSON document.
>>
>> Hope this helps!
>>
>> -John
>>
>>
>>
>>
>> On Sat, Dec 31, 2016 at 8:59 AM, Dharam Thacker <
>> [email protected]> wrote:
>>
>>> Hi Team,
>>>
>>> Wish you all a very happy new year!
>>>
>>> Is there any example on json processing with apache geode?
>>>
>>> Could you help us with below examples on how region definition would
>>> look like?
>>>
>>> *Example*:
>>>
>>> *Case1: Primary key <java.lang.String>*
>>>
>>> region.put(String.valueOf(i), JSONFormatter.fromJSON(obj.toJSONString()));
>>>
>>> For above, I believe it should be --> Region<String,PdxInstance> then
>>> how does it look like in spring data geode xml configuration?
>>>
>>>
>>> *Case2: Primary Key <? extends java.lang.Serializable>*
>>>
>>> region.put (new CustomObject() , JSONFormatter.fromJSON(obj.toJ
>>> SONString()));
>>>
>>> For above, I believe it should be --> Region<CustomObject,PdxInstance>
>>> then how does it look like in spring data geode xml configuration?
>>>
>>> *Case3: Is below case valid one and recommended ?*
>>>
>>> @Region
>>> Class JSONRegion {
>>>      CustomPrimaryKeyObject primaryKey;
>>>      JSONObject jsonObject;
>>>
>>>      // Constructor + Getter/Setter
>>> }
>>>
>>>
>>> More is there any limitation/pros-cons if we store JSON document as
>>> value vs schema bound domain java object?
>>>
>>> Thanks & Regards,
>>> - Dharam Thacker
>>>
>>
>>
>>
>> --
>> -John
>> john.blum10101 (skype)
>>
>
>
>
> --
> -John
> john.blum10101 (skype)
>

Reply via email to