Git Product home page Git Product logo

apex-library's People

Watchers

 avatar

apex-library's Issues

Too many scripts error

What steps will reproduce the problem?
1. When Json object has to parse large amount of json response, due to 
salesforce governance limits it will throw "Too many scripts error".

What is the expected output? What do you see instead?

I am expecting Json object to parse my json response but due to too many 
loopings to parse the data I am getting error.


What version of the product are you using? On what operating system?

SalesSforce, Apex

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 3 Apr 2012 at 7:22

valueToString returns invalid JSON ("}") if JSONObject is empty.

What steps will reproduce the problem?

This should fail, but does not:

1. System.assertEquals('}', new JSONObject().ValueToString());


What is the expected output? What do you see instead?

new JSONObject().ValueToString() should return "{}", not "}"

Please provide any additional information below.

Because ValueToString appends trailing commas to all values, it removes the
last comma in its return statement:

ret.substring(0,ret.length()-1) + '}'

This, of course, is buggy if no values were appended.

Fixes are: 

a. add a trailing space to the "ret" initializer:

string ret = '{ '; // note trailing space

or

b. abandon the substring call (which is performant in java but not
necessarily other languages - unsure of how Apex handles it) and instead
append leading commas for all values except the first..

public String valueToString() {
  string ret = '{';
  for ( string key: this.keys() ) {
    if (ret.size() > 1) ret += ',';
    ret += '"' + key + '": ' + this.getvalue(key).valueToString();
  }
  return ret + '}';  
}

Original issue reported on code.google.com by [email protected] on 24 May 2010 at 1:33

JSON Parsers Throw Syntax Error

The leading JSON Parser from Douglas Crockford 
(http://www.json.org/json2.js) and www.JSONLint.com apparently don't like 
the LValue keys to be without quotes.

Example: {foo: "bar"} should be {"foo": "bar"}

JSONObject.valueToString() doesn't emit quotes around keys. I've updated 
this method as follows to appease various JSON parsers...

public String valueToString() {
    string ret = '{';
    for ( string key: this.keys() ) { 
        ret += '"' + key + '": ' + 
this.getvalue(key).valueToString() + ',';
    }
    return ret.substring(0,ret.length()-1) + '}';
}

Original issue reported on code.google.com by [email protected] on 26 Mar 2010 at 1:21

Parser fails on escaped characters in strings

Attempting to parse an escaped double quote in a double quoted string gave an 
error:

08:56:58.427|FATAL_ERROR|superpat.JSONObject.JSONException: Expected a , or }

Class.superpat.JSONObject.<init>: line 201, column 23
Class.superpat.JSONObject.JSONTokener.nextValue: line 1303, column 35
Class.superpat.JSONObject.<init>: line 186, column 25
Class.superpat.JSONObject.<init>: line 219, column 6
Class.superpat.SimpleGeo.getContextFromAddress: line 32, column 16
AnonymousBlock.superpat: line 3, column 22

The problem was in parsing

{"latitude":37.793755,"longitude":-122.395584,"address":"\"1 Market St, San 
Francisco, CA\""}

Looking at the code, it looks like this was on the 'to do list' :-) I fixed 
enough to get my code working, but I couldn't figure out the Apex for

sb.append((char)Integer.parseInt(next(4), 16));

to handle \u and \x :-/

Patch attached.

Original issue reported on code.google.com by [email protected] on 24 Jan 2011 at 5:04

Attachments:

Expected a , or }

Hi

This parser works fine with Google APIs. I am trying to use elance API to 
search for the jobs and it throws me an exception "Expected a , or }". The JSON 
response of elance and Google looks different.

Would I have to modify this class so that it work with elance API?


Thanks

Original issue reported on code.google.com by [email protected] on 18 Apr 2011 at 7:23

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.