static JsonValue parse(IHjsonDsfProvider[] dsfProviders, String value) { for (int i=0, n=dsfProviders.length; i<n; i++) { IHjsonDsfProvider dsf=dsfProviders[i]; try { JsonValue res=dsf.parse(value); if (res!=null) return res; } catch (Exception exception) { throw new RuntimeException("DSF-"+dsf.getName()+" failed; "+exception.getMessage()); } } return new JsonString(value); }
static String stringify(IHjsonDsfProvider[] dsfProviders, JsonValue value) { for (int i=0, n=dsfProviders.length; i<n; i++) { IHjsonDsfProvider dsf=dsfProviders[i]; try { String text=dsf.stringify(value); if (text!=null) { boolean isInvalid=false; char[] textc=text.toCharArray(); for(char ch : textc) { if (isInvalidDsfChar(ch)) { isInvalid=true; break; } } if (isInvalid || text.length()==0 || textc[0]=='"') throw new Exception("value may not be empty, start with a quote or contain a punctuator character except colon: " + text); return text; } } catch (Exception exception) { throw new RuntimeException("DSF-"+dsf.getName()+" failed; "+exception.getMessage()); } } return null; }
static String stringify(IHjsonDsfProvider[] dsfProviders, JsonValue value) { for (int i=0, n=dsfProviders.length; i<n; i++) { IHjsonDsfProvider dsf=dsfProviders[i]; try { String text=dsf.stringify(value); if (text!=null) { boolean isInvalid=false; char[] textc=text.toCharArray(); for(char ch : textc) { if (isInvalidDsfChar(ch)) { isInvalid=true; break; } } if (isInvalid || text.length()==0 || textc[0]=='"') throw new Exception("value may not be empty, start with a quote or contain a punctuator character except colon: " + text); return text; } } catch (Exception exception) { throw new RuntimeException("DSF-"+dsf.getName()+" failed; "+exception.getMessage()); } } return null; }
static JsonValue parse(IHjsonDsfProvider[] dsfProviders, String value) { for (int i=0, n=dsfProviders.length; i<n; i++) { IHjsonDsfProvider dsf=dsfProviders[i]; try { JsonValue res=dsf.parse(value); if (res!=null) return res; } catch (Exception exception) { throw new RuntimeException("DSF-"+dsf.getName()+" failed; "+exception.getMessage()); } } return new JsonString(value); }