com.hmsonline.json.transformer
Class JsonRule
java.lang.Object
com.hmsonline.json.transformer.JsonRule
- All Implemented Interfaces:
- JsonTransformer
public class JsonRule
- extends Object
- implements JsonTransformer
JSON transforming with condition
- Author:
- baotran
|
Method Summary |
boolean |
check(String fieldName)
|
void |
transform(org.json.simple.JSONObject root)
Walk through fields and apply transforming if field meet condition
Examples:
Remove all PRICE field recursively
{ "PRICE>": "REMOVE" }
Remove CREATED_TIME in sub-elements under ORDER (keep TIME of ORDER)
{"ORDER": { "^CREATED_TIME": { "CREATED_TIME>": "REMOVE" }}} |
void |
transform(org.json.simple.JSONObject root,
Object targetKey)
Transform the target field |
void |
transform(Object target)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JsonRule
public JsonRule(JsonRuleCondition cond,
JsonTransformer transformer)
throws InvalidTransformerException
- Throws:
InvalidTransformerException
transform
public void transform(org.json.simple.JSONObject root,
Object targetKey)
- Transform the target field
- Specified by:
transform in interface JsonTransformer
transform
public void transform(Object target)
- Specified by:
transform in interface JsonTransformer
transform
public void transform(org.json.simple.JSONObject root)
- Walk through fields and apply transforming if field meet condition
Examples:
Remove all PRICE field recursively
{ "PRICE>": "REMOVE" }
Remove CREATED_TIME in sub-elements under ORDER (keep TIME of ORDER)
{"ORDER": { "^CREATED_TIME": { "CREATED_TIME>": "REMOVE" }}}
- Parameters:
root -
check
public boolean check(String fieldName)
Copyright © 2013. All Rights Reserved.