Note that there are some explanatory texts on larger screens.

plurals
  1. POFlexJSON change property name - on Date fields
    primarykey
    data
    text
    <p>I found this bit of code from here: <a href="https://stackoverflow.com/questions/7652231/flexjson-change-prop-name">Change property name with Flexjson</a></p> <p>It works for String data types but seemingly no others. Any ideas?</p> <pre><code>public class FieldNameTransformer extends AbstractTransformer { private String transformedFieldName; public FieldNameTransformer(String transformedFieldName) { this.transformedFieldName = transformedFieldName; } public void transform(Object object) { boolean setContext = false; TypeContext typeContext = getContext().peekTypeContext(); //Write comma before starting to write field name if this //isn't first property that is being transformed if (!typeContext.isFirst()) getContext().writeComma(); typeContext.setFirst(false); getContext().writeName(getTransformedFieldName()); getContext().writeQuoted((String) object); if (setContext) { getContext().writeCloseObject(); } } /*** * TRUE tells the JSONContext that this class will be handling * the writing of our property name by itself. */ @Override public Boolean isInline() { return Boolean.TRUE; } public String getTransformedFieldName() { return this.transformedFieldName; } } </code></pre> <p>This works fine for text fields but gets very unhappy if I try to apply it to a field that is a date. For example:</p> <pre><code> String JSON = new JSONSerializer() .include("type", "createDate") .exclude("*") .transform(new DateTransformer("MM/dd/yyyy"), Date.class) .transform(new FieldNameTransformer("new_json_property_name"),"createDate") .serialize(stuff); </code></pre> <p>Fails with JSONException occured : Error trying to deepSerialize</p> <p>It works fine when I comment out the transform new Field... line and it works fine when I try to change the type field, which is a String. </p> <p>It also fails when trying to modify and Int and I would expect everything else that's not a String.</p> <p>If someone is familiar with the FlexJSON API and can point me in the right direction here I'd very much appreciate it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload